在使用android:layout_weight属性时,控件不能对齐的解决方案

来源:互联网 发布:断点续传java 编辑:程序博客网 时间:2024/05/18 03:24

这个是我写的代码。如果子控件的内容比较多,那么子控件就不能对齐,后来看到鸿洋大神的视频,发现了解决方法,这个要在LinearLayout中加一个
android:baselineAligned="false"  这个属性就可以得到我们想要的结果了


<LinearLayout
android:layout_width="match_parent"
android
:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android
:id="@+id/frag_btn_item_01"
android
:layout_width="match_parent"
android:layout_height="60dp"
android
:layout_weight="1"
android
:text="Customfdggfd "
android:gravity="center"
android
:background="@drawable/item" />
<Button
android:id="@+id/frag_btn_item_02"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android
:gravity="center"
android:text="NetWork"
android:background="@drawable/item" />
<Button
android:id="@+id/frag_btn_item_03"
android:layout_width="match_parent"
android
:layout_height="60dp"
android:layout_weight="1"
android
:gravity="center"
android
:text="Audio dsfsd f"
android
:background="@drawable/item" />
<Button
android:id="@+id/frag_btn_item_04"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android
:text="NOT"
android:gravity="center"
android
:background="@drawable/item" />
</LinearLayout>



加完这个属性之后 : android:baselineAligned="false"



原创粉丝点击