读书人

关于布局文件layout_gravity的有关问题

发布时间: 2012-03-16 16:34:56 作者: rapoo

关于布局文件layout_gravity的问题
我想在屏幕底部放3个imagebutton,做成左中右的布局,但是在tablerow中layout_gravity不起作用,
下面布局文件

XML code
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="#606060"    android:orientation="vertical" >    <RelativeLayout         android:id="@+id/head"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        >    <ImageView         android:id="@+id/title"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:adjustViewBounds="true"        android:contentDescription="@string/title"        android:src="@drawable/play"        />        <ImageButton         android:id="@+id/playOrPause"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:contentDescription="@string/music"        android:adjustViewBounds="true"        android:layout_gravity="right"        android:layout_toRightOf="@id/title"        android:src="@drawable/play"        />    </RelativeLayout>       <FrameLayout        android:id="@+id/middlecontent"       android:layout_width="fill_parent"       android:layout_height="wrap_content"       android:layout_weight="1"              >                 </FrameLayout>          <TableLayout        android:id="@+id/flip"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        >       <TableRow         android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:orientation="vertical"        >                <ImageButton             android:id="@+id/left"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:src="@drawable/left"            android:adjustViewBounds="true"            android:contentDescription="@string/leftye"            />                <ImageButton             android:id="@+id/goContent"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:adjustViewBounds="true"            android:layout_gravity="center"            android:contentDescription="@string/middle"            />                <ImageButton             android:id="@+id/right"             android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:adjustViewBounds="true"            android:src="@drawable/right"            android:layout_gravity="right"            android:contentDescription="@string/rightye"            />               </TableRow>            </TableLayout></LinearLayout>


[解决办法]
你的android:layout_gravity 表示按钮在tablerow界面上的位置把~~

读书人网 >Android

热点推荐