I want to display 6 radio buttons of same radio group. But all the 6 radio buttons remain on same line and goes off the screen. How to display them in two rows (3 radio buttons each)? I tried everything possible for me (I am new to android).
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
A simple answer would be to wrap your RadioGroup in a ScrollView so the user could scroll to the off-screen buttons (not real elegant, but not code intensive either).
From searching around, there doesn't appear to be a way of doing it, as RadioGroup uses LinearLayout, which does not wrap. As radio buttons must be direct children to the radio group, you can't add sub-layouts to radio group.
This means you will have to implement this layout behaviour manually. Two possible options are:
RadioGroup
that extends a layout of your choice, and implementsOnClickListener
. There's a good example here.Dynamically generated by marginTop and marginLeft, to adjust the need to be in the same line of radiobutton. First, get the width of the screen, set the layoutparams marginLeft for the screen width of half, the height of the marginTop needs to be adjusted according to the specific radiobutton.eg: