更改单选按钮的文字出现在侧 [英] Change the side the text appears on a radio button

查看:107
本文介绍了更改单选按钮的文字出现在侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有一种方式来切换文本单选按钮在Android的出现在身边?

I was wondering if there was a way to switch the side that text appears on a radio button in android?

推荐答案

我想要做同样的事情,而不必又扩展另一个类(或两个,你就必须至少延长CompoundButton的的单选按钮)的东西,应该是从一开始就执行工作的一部分。由于我使用的是RadioGroup中,如果你把说,一个单选按钮,并在布局容器一个TextView,这将无法正常工作。我的解决方案固然多了有点hackish,但 - 它的工作原理。

I wanted to do the same thing, without having to extend yet another class (or two, as you would have to at least extend CompoundButton and RadioButton) for something that should be part of the implementation from the beginning. Since I was using a RadioGroup, which will not work if you put say, a RadioButton and a TextView in a layout container. My solution is admittedly more than a bit hackish, but - it works.

1)设置填充左到40 2)设置布局保证金留给-36dp

1) Set Padding left to 40 2) Set Layout margin left to -36dp

在这一点上,原来的单选按钮将视图外,和你的文本视图会坐在最左边的一个4DP保证金。

At this point, the original radio button will be outside the view, and your text view will be sitting on the far left with a 4dp margin.

3)设置可绘制权利@android:绘制/ btn_radio

3) Set Drawable right to @android:drawable/btn_radio

现在,您将拥有一个本地单选按钮在左边的文字和右侧的按钮,这将与一个RadioGroup中。

You'll now have a native RadioButton with the text on the left and a button on the right, that will work with a RadioGroup.

@CommonsWare

@CommonsWare

值得一提的是,这是令人难以置信的讽刺带来了人机界面指南针对此问题的讨论。特别是考虑到调整单选按钮布局放置在最右边的按钮,将实现与微调菜单的布局一致。我完全同意你对此事的看法 - 但它很可能是NickTFried试图弥补Android的挂本身在这方面。

It's worth mentioning that it's incredibly ironic to bring up Human Interface Guidelines in response to this particular question. Especially considering that adjusting the RadioButton layout to place the button on the far right, would achieve consistency with the layout of the Spinner menu. I completely agree with your opinion on the matter - but it's quite possible that NickTFried was trying to compensate for Android "hanging" itself in that regard.

这篇关于更改单选按钮的文字出现在侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆