如何使用Android的布局在每个屏幕尺寸的每部手机上都有完美的尺寸

时间:2011-10-05 16:59:02

标签: android layout android-linearlayout relativelayout

我认为Google会因这些手机的布局而崩溃。比其他所有人更难理解布局。 我的问题是为所有屏幕创建布局。 首先,我必须为活动背景设置图像,然后将图像视图放在顶部,右上角有一个图像按钮。我不知道为什么当我使用这样的东西时:

<LinearLayout android:id="@+id/linearLayout1"
    android:layout_width="match_parent" android:orientation="horizontal"
    android:layout_height="match_parent" android:weightSum="1">
    <ImageView android:id="@+id/imageView1" android:src="@drawable/testotrova"
        android:layout_height="wrap_content" android:layout_weight="0.25"
        android:layout_width="256dip"></ImageView>
    <ImageButton android:layout_width="40dip"
        android:layout_weight="0.25" android:id="@+id/imageButton1"
        android:src="@drawable/info_mini" android:layout_height="50dip"
        android:layout_marginTop="10dip"
        android:scaleType="fitXY"></ImageButton>
</LinearLayout>

模拟器上的imageview是可以的,但是imagebutton的板比图像本身更大。我尝试scaletype但它不会改变任何东西。 当我在不同屏幕尺寸的不同手机上尝试这种布局时,地狱!在一个小屏幕是好的,但在一个比第一个更大的屏幕上,对象更小,并以一种糟糕的方式定位:(我已经为我的应用程序做了所有但不是布局,请帮助我!

1 个答案:

答案 0 :(得分:1)

我在布局中的每个元素上使用LinearLayoutweight解决了问题!

相关问题