如何在Android中调整单选按钮之间的空间 [英] How to adjust space between radio button in android

查看:61
本文介绍了如何在Android中调整单选按钮之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的android应用程序中,使用单选按钮选择屏幕视图.我希望单选按钮水平对齐.我尝试了如下所示的xml布局.

In my android application using radio buttons to select screen view. I want radio button equally aligned horizontal. I tried layout xml shown below.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Views"
    android:paddingLeft="10dp"
    android:textSize="20sp"
    />

<RadioGroup
    android:id="@+id/radioView"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:measureWithLargestChild="true"
    android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/radioViewSingle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:drawableRight="@drawable/single"
            android:layout_weight="1"
            android:checked="true" />

        <RadioButton
            android:id="@+id/radioView2by2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableRight="@drawable/view2x2" />

        <RadioButton
            android:id="@+id/radioView3by3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableRight="@drawable/view3x3" />

        <RadioButton
            android:id="@+id/radioView4by4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableRight="@drawable/view4x4" />
</RadioGroup>
</LinearLayout>

使用上述xml代码获得的输出

output obtained using above xml code

但是我期望输出会低于

预先感谢

推荐答案

使用android:drawableLeft代替使用android:drawableRight.

Instead of using android:drawableRight, use android:drawableLeft.

我刚刚对此进行了测试,并且它按预期运行

I just tested this and it is working as expected

这篇关于如何在Android中调整单选按钮之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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