1.Android基本布局
<LinearLayout android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_height"
android:layout_weight="1"
android:text="aaa"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_height"
android:layout_weight="1"
android:text="bbbbbb"/>
</LinearLayout>
理解一,
1>.看到layout_weight="1" 会错误的理解这两个控制各占剩下空间的50%,奇葩之处:以上理解是错误滴
2>.实际width(TextView-aaa) < width(TextView-bbbbbb)为什么呢?
TextView-aaa的width = w(aaa)+ + 1/2空闲空间
TextView-bbbbbb的width = w(bbbbbb)+ + 1/2空闲空间
3>.如果上面这种情况,那这两个控件不能各占50%
2.修改上面代码:下面情况就可以实现两个控件各占50%
<LinearLayout
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_height"
android:layout_weight="1"
android:text="888"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_height"
android:layout_weight="1"
android:text="999999"/>
</LinearLayout>