我有下面的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();
尝试固定宽度。 – Jayabal 2012-07-18 09:09:49
只是把这样的空间android:text =“简单”也有其他的解决方案,但用这种方式你不必选择任何其他的Android标签,如填充,等等 – 2012-07-18 09:13:13
你的代码对我来说工作正常。发布其他内容你在那里添加什么。 – 2012-07-18 09:13:27