gpt4 book ai didi

android - 如何使 RadioGroup 在 Android 中可滚动?

转载 作者:搜寻专家 更新时间:2023-11-01 08:04:23 28 4
gpt4 key购买 nike

我有一个简单的布局,其中有一个 TextView,然后是一个 RadioGroup,然后是另一个 TextView(最后是一个 Admob 广告 View )。我正在尝试使 RadioGroup 可滚动,但对于我来说,我似乎无法做到这一点。请指教。附上我的 xml 代码。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"

>

<TextView
android:id="@+id/textview_statement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="@string/wait"
android:textSize="18sp"
/>

<ScrollView
android:id="@+id/scrollview_choices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_below="@id/textview_statement"
>

<RadioGroup
android:id="@+id/choices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
>

<RadioButton
android:id="@+id/choice1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/choice" />

<RadioButton
android:id="@+id/choice2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choice" />

<RadioButton
android:id="@+id/choice3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choice" />

<RadioButton
android:id="@+id/choice4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choice" />

<RadioButton
android:id="@+id/dontknow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choice"
android:checked="true" />

</RadioGroup>

</ScrollView>

<Button
android:id="@+id/actonchoice_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adViewQ"
android:layout_marginBottom="2dp"
android:text="@string/actonchoice"
android:onClick="actOnChoice"
android:textSize="12sp"
/>

<com.google.ads.AdView
android:id="@id/adViewQ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId=""
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
/>

</RelativeLayout>

最佳答案

The problem is that whenever the first textview (textview_statement) has a lot of text, one or more radio buttons in the radiogroup are hidden by the button (actonchoice_button). And if I try to scroll, nothing happens. The choices remain hidden by the button.

android:layout_above="@+id/actonchoice_button" 添加到您的 ScrollView 中,表示您希望它的底部边缘锚定到您的顶部按钮。然后,ScrollView 及其 RadioGroup 将不会位于 Button 下。

关于android - 如何使 RadioGroup 在 Android 中可滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16509041/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com