2012-04-11 58 views
1

我设计了以下布局。在wxga屏幕以外的所有尺寸的仿真器上工作都很好。 我也尝试了我的tegra 2动力东芝AC100,但按钮​​并没有对齐到屏幕的右侧,而是收缩和可见的恰到好处的textview。在我兄弟的HVGA xperia mini ST15i上看起来很好。列表视图行布局有imageview,textview和按钮的麻烦?

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 
    <TableRow android:id="@+id/tableRow"> 
    <ImageView android:id="@+id/image" 
       android:layout_width="32dp" 
       android:layout_gravity="center_vertical" 
       android:layout_marginRight="5dp" 
       android:layout_height="32dp" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 
    <TextView android:id="@+id/text" 
       android:layout_width="220dp" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 
    <Button android:id="@+id/button" 
      android:layout_width="60dp" 
      android:layout_alignParentRight="true" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:text="@string/button" 
      android:focusable="false" 
      android:focusableInTouchMode="false" /> 
    </TableRow> 
</TableLayout> 

回答

1

我想出了带有imageview,textview和按钮的listview的布局。它在不同的屏幕方向和大小下工作得非常好。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:id="@+id/relativeLayout" 
       android:layout_height="wrap_content"> 
    <ImageView android:id="@+id/drawable_icon" 
       android:layout_width="36dp" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="5dp" 
       android:layout_alignParentLeft="true" 
       android:layout_height="36dp" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 
    <TextView android:id="@+id/text" 
       android:layout_toRightOf="@id/drawable_icon" 
       android:layout_width="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_marginRight="65dp" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 
    <Button android:id="@+id/button" 
      android:layout_width="60dp" 
      android:layout_alignParentRight="true" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="5dp" 
      android:text="@string/buttonText" 
      android:focusable="false" 
      android:focusableInTouchMode="false" /> 
</RelativeLayout> 
0

也许您可以使用LinearLayout作为ImageView,TextView和Button的父级。在LinearLayout中使用水平方向。 如果您希望孩子在所有情况下都可见,则可以在ImageView,TextView和Button中添加android:layout_weight =“1”属性。