这个是我写的代码。如果子控件的内容比较多,那么子控件就不能对齐,后来看到鸿洋大神的视频,发现了解决方法,这个要在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"