2012-03-24 4 views
7

私はラジオグループの一部であるラジオボタンの賢明な位置付けをしようとしています。ラジオグループが残りのレイアウトデザインの上に座っているときに問題が発生していましたが、マージンを使用してボタンを押していましたが、ここで問題となるのは1つまたは2つのデバイスレイアウトだけです。 RadioGroupを定義し、次にRelativeLayoutを配置することがわかったときに私は金を打ったと思っていました。その下にはRadioButtonの1つが含まれていました。これは私が望むレイアウトを私に与える。問題のように、2つの質問、Android:ラジオグループ内のネストされたレイアウト内のRadioButtonはグループから外れる

  • は、私は戻って、グループにこれらのボタンをリンクすることができ

    :(私は、コードを実行すると、ラジオボタンがリンクスタンドアロンボタンを行動する、ある?

  • があります独立して、グループのラジオ・ラジオボタンのレイアウトを定義することができるようにまともな道。

私は代替が独立したのRadioButtonかもしれ考えていますそれらを有効/無効にするためにコードを使用しますが、これはRadioGroupの有用性を打ち消すものです。

ありがとうございました。

私のXMLレイアウトは興味深いはずです。

<ScrollView android:id="@+id/scrollview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 

     android:layout_below="@id/HDDResultsBox" 
     > 

    <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:windowSoftInputMode="stateHidden" 
    > 


    <RadioGroup android:id="@+id/calcBy" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:layout_below="@id/HDDResultsBox" 

     > 

    <RelativeLayout android:id="@+id/intervalBox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/backgroundbox" 
     android:layout_margin="5dp" 
     android:padding="5dp" 


     > 
      <TextView android:id="@+id/intervalHeader" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Interval" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textStyle="bold" 
      android:layout_marginLeft="5dp" 
      />  

     <TextView android:id="@+id/intervalHelpText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Interval help text" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textSize="8dp" 
      android:layout_toRightOf="@id/intervalHeader" 
      android:layout_marginLeft="10dp" 
      /> 

      <LinearLayout android:id="@+id/interval2ndBox" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_below="@id/intervalHeader" 
      android:layout_marginLeft="10dp" 
      > 
       <RadioButton android:id="@+id/byInterval" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="2dp" 
        /> 

       <EditText android:id="@+id/intervalValue" 
        android:layout_width="75dp" 
        android:layout_height="40dp" 
        android:text="50" 
        android:textSize="14sp" 
        android:gravity="center" 
        android:inputType="number" 
        android:layout_marginLeft="20dp" 
        />  

       <Spinner android:id="@+id/intervalType" 
        android:layout_width="match_parent" 
        android:layout_height="42dp" 
        android:drawSelectorOnTop="false" 
        android:layout_marginTop="1dp" 
        android:layout_marginLeft="10dp" 
        android:layout_weight="10" 
       android:layout_marginRight="2dp" 
        /> 

       <SeekBar android:id="@+id/intervalSeek" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:max="100" 
       android:progress="50" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="8dp" 
       android:layout_weight="7" 
      /> 
      </LinearLayout> 

     </RelativeLayout> 


<RelativeLayout android:id="@+id/recordBox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/backgroundbox" 
     android:layout_margin="5dp" 
     android:padding="5dp" 


     > 
      <TextView android:id="@+id/recordHeader" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Record Duration" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textStyle="bold" 
      android:layout_marginLeft="5dp" 
      />  

     <TextView android:id="@+id/recordHelpText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Record help text" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textSize="8dp" 
      android:layout_toRightOf="@id/recordHeader" 
      android:layout_marginLeft="10dp" 
      /> 

      <LinearLayout android:id="@+id/record2ndBox" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_below="@id/recordHeader" 
      android:layout_marginLeft="10dp" 
      > 
       <RadioButton android:id="@+id/byrecord" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="2dp" 
        /> 

       <EditText android:id="@+id/recordValue" 
        android:layout_width="75dp" 
        android:layout_height="40dp" 
        android:text="50" 
        android:textSize="14sp" 
        android:gravity="center" 
        android:inputType="number" 
        android:layout_marginLeft="20dp" 
        />  

       <Spinner android:id="@+id/recordType" 
        android:layout_width="match_parent" 
        android:layout_height="42dp" 
        android:drawSelectorOnTop="false" 
        android:layout_marginTop="1dp" 
        android:layout_marginLeft="10dp" 
        android:layout_weight="10" 
       android:layout_marginRight="2dp" 
        /> 

       <SeekBar android:id="@+id/recordSeek" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:max="100" 
       android:progress="50" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="8dp" 
       android:layout_weight="7" 
      /> 
      </LinearLayout> 

     </RelativeLayout> 

<RelativeLayout android:id="@+id/playBackBox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/backgroundbox" 
     android:layout_margin="5dp" 
     android:padding="5dp" 


     > 
      <TextView android:id="@+id/playBackHeader" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Video Length" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textStyle="bold" 
      android:layout_marginLeft="5dp" 
      />  

     <TextView android:id="@+id/playBackHelpText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="playBack help text" 
      android:gravity="left" 
      android:textColor="#ffffff" 
      android:textSize="8dp" 
      android:layout_toRightOf="@id/playBackHeader" 
      android:layout_marginLeft="10dp" 
      /> 

      <LinearLayout android:id="@+id/playBack2ndBox" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_below="@id/playBackHeader" 
      android:layout_marginLeft="10dp" 
      > 
       <RadioButton android:id="@+id/byplayBack" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="2dp" 
        /> 

       <EditText android:id="@+id/playBackValue" 
        android:layout_width="75dp" 
        android:layout_height="40dp" 
        android:text="50" 
        android:textSize="14sp" 
        android:gravity="center" 
        android:inputType="number" 
        android:layout_marginLeft="20dp" 
        />  

       <Spinner android:id="@+id/playBackType" 
        android:layout_width="match_parent" 
        android:layout_height="42dp" 
        android:drawSelectorOnTop="false" 
        android:layout_marginTop="1dp" 
        android:layout_marginLeft="10dp" 
        android:layout_weight="10" 
       android:layout_marginRight="2dp" 
        /> 

       <SeekBar android:id="@+id/playBackSeek" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:max="100" 
       android:progress="50" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="8dp" 
       android:layout_weight="7" 
      /> 
      </LinearLayout> 

     </RelativeLayout>  


    </RadioGroup>   
</RelativeLayout> 
     </ScrollView> 
+0

radiogroupを削除し、radiogroupで機能しない場合はボタンを自分で処理します。 button1のようにクリックする:他のすべてのボタンを非アクティブにする。 – zapl

+0

私はあなたがグループをより良くコントロールできないことに失望していますが、私はボタンを手動で使用するようにコードを調整しました。乾杯。 – Purplemonkey

答えて

7

これを行うには、個別のラジオボタンを使用して、オン/オフの状態をプログラムで制御する方法があります。

+1

あなたはGoogleがこれに対する解決策を思いついたと思うだろう。私はこれを "Other"ボタンを作成するときに遭遇しました。ボタンの後にテキストエディットを置くことは非常に困難であることが証明されています... –

関連する問題