我必須在滾動視圖中添加一個文本視圖和兩個單選按鈕,以便讀取所有文本後,用戶可以滾動到最後並選擇一個單選按鈕。 但我無法在滾動視圖中添加這兩個組件,一旦我添加到滾動視圖中的文本視圖中,當我嘗試添加Radio組時,它不會被添加。如何在滾動視圖中添加文本視圖和單選按鈕?
所以請幫助我實現相同。
問候, 皮克斯
我必須在滾動視圖中添加一個文本視圖和兩個單選按鈕,以便讀取所有文本後,用戶可以滾動到最後並選擇一個單選按鈕。 但我無法在滾動視圖中添加這兩個組件,一旦我添加到滾動視圖中的文本視圖中,當我嘗試添加Radio組時,它不會被添加。如何在滾動視圖中添加文本視圖和單選按鈕?
所以請幫助我實現相同。
問候, 皮克斯
由於ScrollView
只能承載一個直接的孩子,你更美好的共同父佈局既添加到即加LinearLayout
或RelativeLayout
您TextView
和RadioGroup
做這樣的事情..
<ScrollView
.......
.......>
<LinearLayout
android:orientation="vertical"
......
......>
<TextView
......
....../>
<RadioGroup
....
..../>
</LinearLayout>
</ScrollView>
這裏不言而喻:
滾動型
的LinearLayout與寬度填充親和高度FILL_PARENT和方向 「垂直」
的TextView
RadiaoGroup
/LinearLayout中
/滾動型
這可能有助於:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textview" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/rb1" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rb2" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rb3" />
</RadioGroup>
</LinearLayout>
</ScrollView>
@Ghost - 在某人可以降級之前,請將您的答案從「CheckBox」更正爲「RadioGroup」。 –
@VivekKalkur:謝謝!沒有看到。 – Ghost
@鬼 - 我的榮幸:-) –