首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

关于布局位置有关问题

2012-07-29 
关于布局位置问题[codeJava][/code]?xml version1.0 encodingutf-8?LinearLayout xmlns:android

关于布局位置问题
[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]
[解决办法]
从上往下分配的

热点排行