2017-02-20 35 views
0
<RelativeLayout 
     android:id="@+id/re1" 
     android:layout_width="match_parent" 
     android:layout_height="85dp" 
     android:layout_below="@+id/view" 
     android:layout_centerHorizontal="true"> 

     <RadioGroup 
      android:id="@+id/radioSex" 
      android:layout_width="match_parent" 
      android:layout_height="455dp" > 

      <RadioButton 
       android:layout_marginTop="10dp" 
       android:id="@+id/alphaa" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Alphabetical(A-Z)" 
       android:checked="true" /> 

      <RadioButton 
       android:layout_marginTop="10dp" 
       android:id="@+id/alphaz" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Alphabetical(Z-A)" /> 
      <RadioButton 
       android:layout_marginTop="10dp" 
       android:id="@+id/distance" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Distance" /> 

     </RadioGroup> 


    </RelativeLayout> 

運行代碼時單選按鈕最後不可見。 xml中的三個單選按鈕,運行代碼最後只顯示不可見,兩個按鈕完美工作。任何想法。andriod中的三個單選按鈕,但最後一個在android studio中不可見

在xml代碼顯示三個按鈕時,我運行代碼它沒有顯示。

+1

變化父佈局到 Android的高度:layout_height = 「WRAP_CONTENT」 – lal

+0

針對此問題提供屏幕截圖。 –

+0

如果您的單選按鈕垂直對齊,然後看看相對佈局的高度,這可能不足以顯示第三個單選按鈕 –

回答

1

您可以做如下:請檢查。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/re1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/view" 
    android:layout_centerHorizontal="true"> 

    <RadioGroup 
     android:id="@+id/radioSex" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RadioButton 
      android:id="@+id/alphaa" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:checked="true" 
      android:text="Alphabetical(A-Z)" /> 

     <RadioButton 
      android:id="@+id/alphaz" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:text="Alphabetical(Z-A)" /> 

     <RadioButton 
      android:id="@+id/diswtance" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:text="Distance" /> 

    </RadioGroup> 


</RelativeLayout> 

更改主版面的高度bro ...你不應該在你的根佈局中使用fix dp作爲高度。您可以使用wrap_content或match_parent。

0

更改RelativeLayout佈局高度。

wrap_content

設置視圖的尺寸爲wrap_content將迫使它擴大隻是遠遠不夠,以遏制它所包含的值(或子控件)。

<RelativeLayout 
     android:id="@+id/re1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 


Your Radio group 

</RelativeLayout> 
0

集機器人:layout_height = 「WRAP_CONTENT」

<RelativeLayout 
    android:id="@+id/re1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/view" 
    android:layout_centerHorizontal="true"> 
     <RadioGroup 
     android:id="@+id/radioSex" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 


     . 
     . 
     . 
     </RadioGroup> 
    </RelativeLayout> 
相關問題