【问题标题】:How can I align radio button in android如何在android中对齐单选按钮
【发布时间】:2010-07-25 04:14:03
【问题描述】:

我正在尝试在我的 android 应用程序中使用收音机组/单选按钮的以下示例。 http://www.androidpeople.com/android-radiobutton-example/

但单选按钮位于标签(文本)的左侧。

您能否告诉我如何配置它以使单选按钮位于标签的右侧?并且文本与父级左对齐,单选按钮与父级右侧对齐?

谢谢。

【问题讨论】:

标签: android


【解决方案1】:

右侧对齐单选按钮:

<RadioButton
                    android:id="@+id/radio0"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:button="@null"
                    android:checked="true"
                    android:drawableRight="@drawable/presets_sel"
                    android:padding="12dp"
                    android:text="RadioButton 1" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/right_arrow_h" android:state_checked="true"/>
    <item android:drawable="@drawable/right_arrow_h" android:state_pressed="true"/>
    <item android:drawable="@drawable/right_arrow"></item>

</selector>

【讨论】:

    【解决方案2】:

    我做了很详细的回答here。这个问题经常出现,就像我需要仔细格式化 RadioButtons 的情况一样!

    祝你好运!

    【讨论】:

    • 那么你不应该重新回答,而是将其标记为重复。
    猜你喜欢
    • 2011-05-12
    • 2017-01-16
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 2017-01-10
    • 2016-06-09
    • 1970-01-01
    • 2016-04-08
    相关资源
    最近更新 更多