2012-04-11 13 views
1

私は次のレイアウトを設計しました。 wxgaの画面を除くすべてのサイズのエミュレータでうまく動作します。 私はtegra 2 powered Toshiba AC100でも試しましたが、ボタンは画面の右に揃えられていません。私の兄弟のHVGA xperia mini ST15iは上手く見えます。イメージビュー、テキストビュー、ボタンを持つリストビューの行レイアウトに問題がありますか?

<?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、buttonを使って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

ImageView、TextView、およびButtonの親に対してLinearLayoutを使用できます。 LinearLayoutでは、水平方向を使用します。 すべての状況で子を表示する場合は、ImageView、TextView、およびButtonでandroid:layout_weight = "1"属性を追加できます。

関連する問題