2012-07-18 63 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模拟器。在我安装我的应用程序后,启动我的应用程序并显示收音机组,我看到了问题。但是,当我使用返回键返回到主屏幕并启动我的应用程序并再次显示收音机组时,我看不到问题!