要让LinearLayout内的子控件平分需要使用布局内的一个属性 layout_weight
这个属性的意思是比重,设置多大就表示需要占据父控件的多少空间,越大占的比重越大。
如果要让子空间平分,仅仅将所有子控件的layout_weight的属性设置为1是不行的,
当子控件内的内容不一样时,会出现不平分的情况,这个时候就 要将每个子控件的layout_width设置为0dip
例子:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:layout_weight="2"
android:text="提交"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
具体可以参考官方文档
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。