2012-05-05 11 views
1

私は相対レイアウトを使用してテーブル行の設定をしています。それは2つTextViewを持っていますが、私は等間隔と左揃えのテキストを持っています。以下の現在の設定を参照してください。これは、1つのテキストビューが左揃えと右揃えになっています。私は両方の左のコンテンツの重なりに合わせるために変更するとき。AndroidのRelativeLayoutと等価アライメント

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout02" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dip"> 
    <TextView 
     android:id="@+id/displayLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="20dp" 
     android:layout_toRightOf="@+id/row_image" 
     android:text="adasd" 
     android:textSize="18sp" />  
    <TextView 
     android:id="@+id/displayValue" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="20dp" 
     android:text="adasd"  
     android:textSize="18sp"/> 

</RelativeLayout> 

提案があります。助けを前にありがとう。

答えて

1

それは加重のLinearLayoutのための仕事のように思える - ディスプレイ2 equalyサイズのテキストビュー:

エミュレータで次に
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout02" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dip"> 

    <TextView 
     android:id="@+id/displayLabel" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"   
     android:layout_marginLeft="20dp" 
     android:text="adasd" 
     android:textSize="18sp" 
     android:layout_weight="1"/> 

    <TextView 
     android:id="@+id/displayValue" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"   
     android:layout_marginRight="20dp" 
     android:text="adasd"  
     android:textSize="18sp" 
     android:layout_weight="1"/> 

</LinearLayout>  

それは意志のようになります。 screenshot

注両方のテキストビューでlayout_weight属性ゼロはlayout_widthです。基本的には、ビューは指定された重みに比例した余分な空き領域を取得することを意味します。等価ウェイトの場合、これらのビューは同じ幅になります。

さらに参照するためにlayout guide on developer.android.comを参照してください。

0

alignParentRightの代わりにdisplayValue TextViewを次のように使用してみましたか?

android:layout_toRightOf="@id/displayLabel" 

次に、余白をいくつか与えます。