我有下面的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