简体   繁体   English

带有右对齐检查按钮/框的Android CheckBox

[英]Android CheckBox with right-aligned checking button/box

I am fairly new to Android (find it most fun, btw) and I was wondering... 我是Android的新手(发现它最有趣,顺便说一下),我想知道......

How can I create an Android CheckBox with the label to the left and the checking button/box aligned to the right (pretty much a switch of the way this widget is drawn by default)? 如何创建一个Android CheckBox,左边是标签,右边是检查按钮/框(默认情况下是这个小部件的绘制方式)? Like the way a checkbox preference normally looks like... 就像复选框偏好通常看起来的方式一样......

I am looking for the most elegant/short-coded version possible, if there is one. 我正在寻找最优雅/短编码的版本,如果有的话。 I mean other than creating your own View/ViewGroup with layouts, empty-labeled CheckBoxes and TextViews, etc... 我的意思是除了使用布局创建自己的View / ViewGroup,空标记的CheckBoxes和TextViews等...

Thanks & Regards, 感谢和问候,

尝试使用CheckedTextView ,它是多选ListView小部件使用的小部件。

CommonsWare's answer is absolutely right but there is one more option which you can use and it's quite easier than CheckedTextView. CommonsWare的答案是绝对正确的,但是你可以使用另外一个选项,它比CheckedTextView更容易。 You can use *simple_item_list_multiple_choice* . 您可以使用* simple_item_list_multiple_choice * it will create list with chekcbox and labels on left and as on the name of extra work you just have to define one ListView in your main.xml nothing else. 它将在左侧创建带有chekcbox和标签的列表,并且在您需要在main.xml中定义一个ListView的额外工作的名称上没有别的。

I hope it will help. 我希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - 使用右对齐视图进行布局椭圆化 - Android — Layout ellipsize with right-aligned view 在Android上列出布局,如何使按钮右对齐? - List Layout on Android, how to make buttons right-aligned? Android-如何强制微调框下拉列表打开右对齐 - Android - How to force spinner dropdown to open right-aligned 当屏幕宽度较小时,如何在右对齐按钮旁边省略居中对齐的文本视图 - How to ellipsize center-aligned textview beside a right-aligned button when screen width is small 具有右对齐,裁剪,未缩放内容的ImageView - ImageView with right-aligned, cropped, unscaled content 如何在不重叠滚动条的情况下显示 Android 右对齐 ListItem 数据? - How to show Android Right-aligned ListItem data without overlapping the scrollbar? ListView行样式 - 左对齐文本和右对齐图标 - ListView row styling - left aligned text, and right-aligned icon RelativeLayout不会包装右对齐的TextView - RelativeLayout won't wrap right-aligned TextView 我想在android中创建自定义标签栏,标签必须右对齐,内容必须在左侧 - I want to create custom tab bar in android, The tabs must be right-aligned and contents must be at the left-side ImageButton(右对齐,固定宽度)和EditText(左对齐,剩余空间宽度) - ImageButton (right-aligned, fixed width) and EditText (left-aligned, remaining space width)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM