2016-10-17 5 views
0

問題は、私がmatch_parentに正しく到達することができないということです。私がしたいのは、下の画像のようにページの最後まで広げることです。 私は実際にすべてを試しましたが、私が思いついた唯一の解決策は、固定されたpxを追加することです。これは、異なるプラットフォーム間で競合するため、やりたくないことです。私は取得しています何radiogroupをmatch_parentを使って均等に水平に伸ばす

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="net.battleplugins.msutton.fragemento.MainActivity"> 
    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/menu_row"> 

      <RadioGroup 
       android:layout_width="match_parent" 
       android:layout_height="75dp" 
       android:orientation='horizontal'> 

       <RadioButton 
        android:text="@string/quiz_button_title" 
        android:layout_width="fill_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/quiz_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 

       <RadioButton 
        android:text="@string/picture_button_title" 
        android:layout_width="fill_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/picture_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 


       <RadioButton 
        android:text="@string/events_button_title" 
        android:layout_width="fill_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/events_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 
      </RadioGroup> 
     </TableRow> 
    </TableLayout> 

</RelativeLayout> 

はこれです:

Image of the emulation where it doesn't extend like match_parent is intended

私はそれがやりたいことはこれです:これに伴う問題は、これがあることである

Image of the emulation correctly spaced but with fixed width

固定金額。 アンドロイド:RADIOGROUP

答えて

1

でlayout_width = "1075px" あなたの代わりのLinearLayoutを使用することができます。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:orientation="horizontal" 
    tools:context="net.battleplugins.msutton.fragemento.MainActivity"> 
      <RadioGroup 
       android:layout_width="match_parent" 
       android:layout_height="75dp" 
       android:orientation='horizontal'> 

       <RadioButton 
        android:text="@string/quiz_button_title" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:id="@+id/quiz_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 

       <RadioButton 
        android:text="@string/picture_button_title" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:id="@+id/picture_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 


       <RadioButton 
        android:text="@string/events_button_title" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:id="@+id/events_button" 
        android:button="@android:color/transparent" 
        android:background="@drawable/buttonbackground" 
        android:layout_weight="1" 
        android:onClick="updateFragment"/> 
      </RadioGroup> 
</LinearLayout> 
+0

あなたは神かもしれません。どうもありがとうございます。 – sheepiiHD

1

のLinearLayoutは、これを達成するための最良のアプローチです。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    tools:context="net.battleplugins.msutton.fragemento.MainActivity"> 
    <RadioGroup 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:orientation='horizontal'> 

     <RadioButton 
      android:text="@string/quiz_button_title" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/quiz_button" 
      android:button="@android:color/transparent" 
      android:background="@drawable/buttonbackground" 
      android:layout_weight="1" 
      android:onClick="updateFragment"/> 

     <RadioButton 
      android:text="@string/picture_button_title" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/picture_button" 
      android:button="@android:color/transparent" 
      android:background="@drawable/buttonbackground" 
      android:layout_weight="1" 
      android:onClick="updateFragment"/> 


     <RadioButton 
      android:text="@string/events_button_title" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/events_button" 
      android:button="@android:color/transparent" 
      android:background="@drawable/buttonbackground" 
      android:layout_weight="1" 
      android:onClick="updateFragment"/> 
    </RadioGroup> 
</LinearLayout> 
0

あなたがTableLayoutを使用したい場合は、あなたのRadioGroupであなたのTableLayoutandroid:layout_column="1"android:stretchColumns="1"を指定します。

0

絶対幅を設定する代わりに、重みを使用します。

<RadioGroup 
       android:weightSum="3" 
       android:layout_width="match_parent" 
       android:layout_height="75dp" 
       android:orientation='horizontal'> 
       <RadioButton 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 

       <RadioButton 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 


       <RadioButton 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 
</RadioGroup> 
関連する問題