读书人

关于布局位置有关问题

发布时间: 2012-07-29 15:26:14 作者: rapoo

关于布局位置问题
[code=Java][/code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="我是第一个tv" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="按钮一" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="我是第二个tv" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="按钮二" />
</LinearLayout>

</LinearLayout>
第二个布局为什么不在整体布局的底端

[解决办法]

XML code
<?xml version="1.0" encoding="utf-8"?>[color=#FF0000]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent" >[/color]  <LinearLayout  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:orientation="horizontal" >  <TextView  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_weight="1"  android:text="我是第一个tv" />  <Button  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_weight="1"  android:text="按钮一" />  </LinearLayout>      <LinearLayout  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:orientation="horizontal"  [color=#FF0000]android:layout_alignParentBottom="true" [/color]>  <TextView  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_weight="1"  android:text="我是第二个tv" />  <Button  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_weight="1"  android:text="按钮二" />  </LinearLayout>[color=#FF0000]</RelativeLayout>[/color]
[解决办法]
从上往下分配的

读书人网 >Android

热点推荐