2012-01-06 56 views
-1

的我使用的是相對佈局內的單選按鈕,這裏是我的代碼我的單選按鈕外出屏幕

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="fill_parent" > 

<FrameLayout android:id="@+id/frameLayout" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_alignParentTop="true" 
    android:layout_above="@+id/radioButtonGroupLayout"> 
<!-- Put fragments dynamically --> 

</FrameLayout> 


<RadioGroup android:id ="@+id/radioButtonGroupLayout" android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" android:layout_alignParentBottom="true"> 

    <RadioButton android:id="@+id/RadioButton1" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_1_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton2" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_2_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton3" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_3_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton4" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_4_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton5" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_5_selector" android:background="@drawable/ip4_menu_background_short72"/> 
</RadioGroup> 
</RelativeLayout> 

最後一個單選按鈕都沒有在屏幕上。我只能看到前4個單選按鈕,而且最後一個按鈕很多。我的代碼有什麼問題?

+0

你能給我們看一個截圖嗎?這是可能的,因爲您正在使用wrap_content作爲單選按鈕,它們顯示的大小與您用於按鈕和背景的可繪製對象相同。我會建議改變這些高度和寬度到一個固定的DP,這樣它會更好地擴大到更大/更小的屏幕。 – 2012-01-06 10:21:41

+0

謝謝邁克爾,我改變了圖像大小,並且還向所有單選按鈕添加了layout_weight =「1」來分配剩餘的空間..並且它的工作...感謝您的所有幫助 – Nik 2012-01-06 10:29:28

+1

嘗試將所有內容嵌套在滾動視圖中。 – Ghost 2012-01-06 10:29:41

回答

0

這是可能的,因爲您正在使用wrap_content作爲單選按鈕,它們顯示的尺寸與您用於按鈕和背景的可繪製尺寸一樣大。我會建議改變這些高度和寬度到一個固定的DP,這樣它會更好地擴大到更大/更小的屏幕。

添加了評論作爲答覆,讓這個問題被關閉。

0

使用android:layout_weight =「1」與每個單選按鈕。它會顯示任何大小的屏幕上的所有5個按鈕。

<RadioButton 
     android:id="@+id/RadioButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" /> 

請對所有單選按鈕做同樣的操作。