0

を圧迫されて、私はhttps://github.com/Kaopiz/android-segmented-controlからセグメント化されたコントロールを使用していますが、最後のボタンは、常にこのよう絞られる以外、それはかなりうまく動作します:がSegmentedGroup - 最後のボタンが

segmented control

私はシンプルなレイアウトを使用して動的にラジオボタンを追加してい:

<RadioButton xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    style="@style/RadioButton" /> 

Layout_width = "content wrap"のような変形を試み、layout_weightを削除しました。同じ結果です。セグメント化されたコントロール自体の 親のレイアウトにも何のヒントを与えていない:このトピックで偶然見つけ

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:layout_marginRight="15dp" 
     android:background="@color/white" 
     android:gravity="center" 
     android:minHeight="60dp"> 

     <info.hoang8f.android.segmented.SegmentedGroup 
      android:id="@+id/segmentedGroup" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      segmentedgroup:sc_border_width="1dp" 
      segmentedgroup:sc_corner_radius="10dp" 
      segmentedgroup:sc_tint_color="#FFEB3B"> 


     </info.hoang8f.android.segmented.SegmentedGroup> 
    </RelativeLayout> 

答えて

0

回答:

Programmatically-added RadioButtons refuse to obey LayoutParams weighting

だけでレイアウトを設定することRADIOGROUPにボタンを追加する前に、プログラムparamsは所望の効果を達しました

RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f); 
    radioButton.setLayoutParams(layoutParams); 
関連する問題