2016-09-28 4 views
1

は、私たちはこの絵のようなアンドロイドでラジオ・グループを設計することができますする方法を尋ねたいスタイルラジオ・グループは、Android

My Radio Button「マイスタイル」

アイムこのようなデザインのXML:

<RadioGroup 
     android:layout_below="@+id/btnGroup" 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <RadioButton 
       android:id="@+id/rdiEasy" 
       android:text="EASY" 
       android:layout_alignParentLeft="true" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <RadioButton 
       android:id="@+id/rdiMedium" 
       android:text="MEDIUM" 
       android:layout_marginRight="8dp" 
       android:layout_alignParentRight="true" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </RelativeLayout> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <RadioButton 
       android:id="@+id/rdiHard" 
       android:text="HARD" 
       android:layout_alignParentLeft="true" 

       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <RadioButton 
       android:id="@+id/rdiHardest" 
       android:text="HARDEST" 
       android:layout_alignParentRight="true" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </RelativeLayout> 
    </RadioGroup> 

RadioButtonGroupラップ2 RelativeLayoutを使用しています。各RelativeLayoutには2つのラジオボタンがあります。しかし、このデザインでは、ラジオボタンを1つしか選択できず、マルチラジオボタンを選択できます。誰も私にこのデザインのラジオボタンをデザインする方法を手伝ってもらうことができます。

+0

は、(二のLinearLayoutを使用する選択されたかどうかを確認相対的なレイアウトではなく、縦向きのLinearLayout内で水平方向に移動します。 –

+0

あなたの情報のためにRadioGroupにはRadioButtonが含まれている必要があります –

+0

返信ありがとう、私はRadioGroupの選択モードでプロンプトを持っていることを意味します!私のコードで私はこのデザインを実装することができますが、1つのオプション(ラジオボタングループは機能しません)を選択することはできません – EddyLee

答えて

-1
+0

私はこのデザインを実装することができます、私はちょうどRadioButtonGroupとproplemを持っています。私は1つの選択肢しか選べません。それでもマルチオプション – EddyLee

+0

ねえEddyLee私は自分のコードを変更&それは私がそれだけで一つの無線を選択します今同じのためにそれをチェックしてみてください –

+0

はい、私はあなたのコードを見ましたが、それでもproplemをお持ちの作品選択することができます:あなたは2は、RadioButtonGroupを持っているが、私は1/4オプションを選択したいので、1つのラジオボタングループが必要です – EddyLee

0

はそれが完璧に動作し、このコードを使用するためにこれが機能すると思います。

<RelativeLayout 
    android:id="@+id/rl1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true"> 

    <RadioGroup 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:orientation="horizontal" 
     android:transitionGroup="true"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="30dp"> 

      <RadioButton 
       android:id="@+id/rdiEasy" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Easy" /> 

      <RadioButton 
       android:id="@+id/rdiHard" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Hard" /> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="30dp"> 

      <RadioButton 
       android:id="@+id/rdiMedium" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/rdiEasy" 
       android:text="Medium" /> 

      <RadioButton 
       android:id="@+id/rdiHardest" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/rdiHard" 
       android:text="Hardest" /> 

     </LinearLayout> 
    </RadioGroup> 
</RelativeLayout> 
+0

を使用することができますことができますまだproplemをお持ちのレイアウトやスタイルの助け以内にそれのため – EddyLee

+0

の両方の4つのオプションがここで線形レイアウトのために問題を起こしています。私はまもなくアップデートします。 –

0

、重力を設定することにより、所望のパターンを達成しようとradiogroup.and内部レイアウトを使用せずにこのコードを試してみて、このようなラジオボタンは、1つまたは複数

<RadioGroup 
    android:id="@+id/radioGroup" 
    android:layout_width="500dp" 
    android:layout_height="250dp" 
    android:layout_weight=".07" 
    android:gravity="center"> 


    <RadioButton 
     android:id="@+id/radioButton2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left|top" 
     android:layout_marginLeft="5dp" 
     android:text="New RadioButton" /> 

    <RadioButton 
     android:id="@+id/radioButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right|top" 
     android:layout_marginRight="5dp" 
     android:text="New RadioButton" /> 

    <RadioButton 
     android:id="@+id/radioButton4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|left" 
     android:layout_marginLeft="5dp" 
     android:text="New RadioButton" /> 

    <RadioButton 
     android:id="@+id/radioButton3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|right" 
     android:layout_marginRight="5dp" 
     android:text="New RadioButton" /> 

</RadioGroup> 
関連する問題