Android 如何在自定义对话框中放置多个linearlayout?
我创建了一个自定义对话框,其中包含在运行时填充的单选按钮。如果单选按钮的数量超过12,则底部线性布局(带按钮)不显示。我怎样才能解决这个问题?我的代码Android 如何在自定义对话框中放置多个linearlayout?,android,android-layout,layout,Android,Android Layout,Layout,我创建了一个自定义对话框,其中包含在运行时填充的单选按钮。如果单选按钮的数量超过12,则底部线性布局(带按钮)不显示。我怎样才能解决这个问题?我的代码 包装滚动视图的线性布局在高度上设置为“包装内容”,列表越大,按钮就会被推出屏幕 我建议使用,它允许您相对彼此定位您的视图。例如,“按钮始终在父级底部对齐,滚动视图始终在按钮上方和父级顶部下方”只需将父级线性布局替换为框架布局,并将底部容器(线性布局)重力设置为底部 <FrameLayout xmlns:android = "
包装滚动视图的线性布局在高度上设置为“包装内容”,列表越大,按钮就会被推出屏幕
我建议使用,它允许您相对彼此定位您的视图。例如,“按钮始终在父级底部对齐,滚动视图始终在按钮上方和父级顶部下方”只需将父级线性布局替换为框架布局,并将底部容器(线性布局)重力设置为底部
<FrameLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:padding = "16dp">
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginBottom = "100dp">
<ScrollView
android:layout_width = "match_parent"
android:layout_height = "match_parent">
<RadioGroup
android:id = "@+id/input_radio_button_radiogroup"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"></RadioGroup>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_gravity="bottom"
android:orientation = "horizontal">
<Button
android:id = "@+id/input_radio_button_custom_cancel_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginRight = "4dp"
android:layout_weight = "1"
android:text = "Cancel" />
<Button
android:id = "@+id/input_radio_button_custom_ok_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginLeft = "4dp"
android:layout_weight = "1"
android:text = "Ok" />
</LinearLayout>
ConstraintLayout将解决其中一些问题,但实际上这应该是一个recyclerView。不要使用它,而是使用RecyclerViewsCollView将是一个更好的选择,而不是recyclerView。
<FrameLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:padding = "16dp">
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginBottom = "100dp">
<ScrollView
android:layout_width = "match_parent"
android:layout_height = "match_parent">
<RadioGroup
android:id = "@+id/input_radio_button_radiogroup"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"></RadioGroup>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_gravity="bottom"
android:orientation = "horizontal">
<Button
android:id = "@+id/input_radio_button_custom_cancel_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginRight = "4dp"
android:layout_weight = "1"
android:text = "Cancel" />
<Button
android:id = "@+id/input_radio_button_custom_ok_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginLeft = "4dp"
android:layout_weight = "1"
android:text = "Ok" />
</LinearLayout>