好吧,我有线性布局两个按钮:
Ok, i have two buttons in linear layout:
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button android:id="@+id/aktiviraj_paket"
android:text="Aktiviraj"
android:layout_height="40sp"
android:layout_width="160sp"
android:background="@drawable/my_border3"
android:onClick="myClickHandle"></Button>
<Button android:id="@+id/deaktiviraj_paket"
android:text="Deaktiviraj"
android:layout_height="40sp"
android:layout_width="fill_parent"
android:background="@drawable/my_border3"
android:onClick="myClickHandle">
</Button>
</LinearLayout>
所以,问题是,如果我用填充母的两个按钮,它们是一个在对方,所以我做了第一个按钮160SP宽度,二是FILL_PARENT。如果这是显示在4英寸屏幕或更小,按钮的大小相同,但如果我尝试这对平板电脑(10英寸)的第一个按钮保持160SP宽,二是延伸到屏幕的末尾(因为FILL_PARENT)。我可以做这个,所以这两个按钮可能会更规模无论大小的屏幕??
So the thing is, if I use fill parent on both buttons, they are one on each other, so i have made first button 160sp width, and second is fill_parent. If this is shown on 4 inch screen or smaller, buttons are the same size, but if i try this on tablet (10 inch) first button stays 160sp wide, and second is stretched till the end of screen (because fill_parent). Can i make this, so both buttons could be even size in no matter what size is the screen ??
使用的android:layout_weight =1
在两个按钮
秒。设置机器人:layout_width =0dp
两个。由于这两个按钮现在有相等的权重,他们现在各有一半的父母的宽度。
Use android:layout_weight="1"
on both Button
s. Set android:layout_width="0dp"
on both. Since both buttons now have equal weighting, they will now each have half the parent's width.
您可以点击这里找到:http://developer.android.com/guide/topics/ui/layout/linear.html
上一篇:嵌套preferences.xml嵌套、preferences、xml
下一篇:FragmentStatePagerAdapter IllegalStateException异常:其中,MyFragment&GT;是当前不在FragmentManager异常、IllegalSta