2011-12-09 18 views
1

私は左側にテキストビュー、右側にラジオグループがあります。ラジオグループにボタンを入れる前に、画面の右側にボタンがありました。私はそれをRadioGroupに入れて間違っていますか?ボタンはRadioGroupの内側にあるためAndroidグループで右揃えのラジオグループ

<RelativeLayout 
      android:id="@+id/relativeLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.25" > 

    <TextView 
       android:id="@+id/textView2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@+id/radioButton1" 
       android:layout_alignParentLeft="true" 
       android:text="@string/hair" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

      <RadioGroup 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 


      <RadioButton 
       android:id="@+id/radioButton1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:text="@string/Yes" /> 

      <RadioButton 
       android:id="@+id/radioButton2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/radioButton1" 
       android:layout_below="@+id/radioButton1" 
       android:text="@string/No" /> 



      </RadioGroup> 


     </RelativeLayout> 

答えて

3

あなたは個別のボタンに設定した「揃える」のパラメータ(のようなlayout_alignParentRight)のすべてがLinearLayoutのサブクラスである、もはや有効ではありません。グループ全体を右揃えにするには、RadioGroup自体に適切なパラメータを追加する必要があります。

また、fill_parentの代わりにの幅をwrap_contentにすることもできます。さもなければ、コンテナが利用可能なすべてのスペースを埋めるようにしようとすると、水平レイアウトのアラインメントが見えなくなる可能性があります。

HTH

+0

これはトリックでした!それを指摘してくれてありがとう! – Intelwalk

0

また、あなたのRadioGroupにこれを追加することができますし、それがうまくaswellに動作します!

android:gravity="center|left"