纯布局问题:代码如下:
android:id="@+id/linear_bottom"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000" >
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#f00"
android:orientation="horizontal" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#fff"
android:text="1111"
android:textSize="40dp" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#fff"
android:text="2222"
android:textSize="30dp" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#fff"
android:text="3333"
android:textSize="10dp" />
效果图:
结果无法顶部对齐,或底部对齐,只可以居中。
方案一:将padding和margin全部设为0,失败
android:padding="0dp"android:layout_margin="0dp"
方案二:添加布局位置对齐,失败
android:layout_gravity="top" android:gravity="top"
解决方案:
外层linearlayout添加属性 android:baselineAligned="false",若无则导致了后面的两个textview已第一个textview为基准线, 导致设置android:layout_gravity="bottom"或者top时后面的两个textview没有对齐