2012-07-19 82 views
1

我现在使用dip。但在具有mdpi,hdpi,xhdpi ...比例的设备上有所不同。例如: enter image description here如何设置图层的大小百分比?

我知道在mdpi 1px = 1dp。 华电国际1.00dp = 1.50px xhdpi 1.00dp = 2.00px

在高分辨480x800的华电国际,上xhdi usualy 720x1280 ... DP是没用的

回答

4

使用android:layout_weight="25",继续等,并依此类推,直到你在你的LinearLayout完成所有项目。

因此,例如:

android:layout_weight="25" 
android:layout_weight="15" 
android:layout_weight="50" 
android:layout_weight="35" 
1

你应该用 '机器人:layout_weight' PARAM LinearLayout孩子:

<LinearLayout> 
    <View 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:layout_weight="25" /> 
    <View 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:layout_weight="15" /> 
    <View 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:layout_weight="50" /> 
    <View 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:layout_weight="35" /> 
</LinearLayout> 
0

虽然无法从XML做到这一点,BYTü可以随时设置宽度,通过计算得到的高度(取决于屏幕的总大小,并相应地设置您的视图的参数),如在此链接中一样

link

相关问题