2012-07-18 64 views
1

我有下面的xml代碼,我用它來顯示在對話框中。問題在於「Easy」中的字母「E」顯示在單選按鈕本身下。所以它不可見。這是爲什麼?剩下的部分將在每個對應的RadioButton的右側正確顯示。Android。 Radiobutton文本將無法正確顯示

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

<RadioGroup 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <RadioButton 
     android:id="@+id/radioBtnEasy" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:text="Easy" 
     android:layout_weight="1" /> 

    <RadioButton 
     android:id="@+id/radioBtnMedium" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:checked="true" 
     android:text="Medium"    
     android:layout_weight="1" /> 

    <RadioButton 
     android:id="@+id/radioBtnHard" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:text="Hard" 
     android:layout_weight="1" /> 
</RadioGroup> 

編輯

在帕德瑪·庫馬爾的要求,我張貼代碼的其餘部分。這是我如何顯示對話框。我使對話框的寬度適合屏幕的寬度,而不是環繞內容。 我刪除了這個,但它仍然顯示錯誤的簡單文本。

//Define a new dialog window 
    Dialog dialog = new Dialog(this); 
    //Load the predefined layout onto this dialog 
    dialog.setContentView(R.layout.new_session_dialog); 
    //Set title of dialog 
    dialog.setTitle("Create new session"); 
    //Set the width of the dialog to fill the width of the screen 
    dialog.getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); 

    //Show the dialog 
    dialog.show(); 
+1

嘗試固定寬度。 – Jayabal 2012-07-18 09:09:49

+0

只是把這樣的空間android:text =「簡單」也有其他的解決方案,但用這種方式你不必選擇任何其他的Android標籤,如填充,等等 – 2012-07-18 09:13:13

+0

你的代碼對我來說工作正常。發佈其他內容你在那裏添加什麼。 – 2012-07-18 09:13:27

回答

1

使用android:EMS屬性,但所有密度裝置

0

嘗試首先刪除layout_weight = 1,並將fill_parent放在RadioButton寬度上。然後做必要的調整。

1

的0dp寬度是最有可能的問題上管理你的文字,

否則,如果只有第一個字符「E」不被顯示,在Easy之前放置一個空間。

例)而不是「簡單」把「簡單」

1

感謝您發佈此問題。我遇到了同樣的問題:第一個單選按鈕中的圖標踩在後面文本的第一個字母上。我正在使用Android 1.6模擬器。在我安裝我的應用程序後,啓動我的應用程序並顯示收音機組,我看到了問題。但是,當我使用返回鍵返回到主屏幕並啓動我的應用程序並再次顯示收音機組時,我看不到問題!