如何把图像到一个单选按钮,Android的权

问题描述:

我试图做的4项单选按钮列表。每个项目需要有文字它是正确的,而且对文本的右侧的图像。的图像不是单选按钮本身,它的描述选项的图像。
我至今没有运气,设计者似乎没用放东西的地方。你必须知道如何code此XML格式。
我的XML看起来是这样的:

I am trying to make a radio button list of 4 items. Each items need to have text to it's right, but also an image to the right of the text. The image is not the radio button itself, it's an image describing the option. I have no luck so far, the designer seem to be useless to put things in place. You have to know how to code this in XML. My XML looks like this:

<?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:weightSum="1" android:baselineAligned="true" android:orientation="horizontal">
    <RadioGroup android:layout_weight="0.50" android:layout_height="wrap_content" android:id="@+id/radioGroup1" android:layout_width="0dp">
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true" android:text="A" android:id="@+id/radio0"></RadioButton>
        <ImageView android:layout_toRightOf="@id/radio0" android:layout_height="wrap_content" android:src="@drawable/A2" android:layout_width="wrap_content" android:id="@+id/imageView1"></ImageView>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="B" android:id="@+id/radio1"></RadioButton>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="C" android:id="@+id/radio2"></RadioButton>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="D" android:id="@+id/radio3"></RadioButton>
    </RadioGroup>

</LinearLayout>

在这里,我tryiong把一个图像到第一个单选按钮的右侧,没有成功。
我要如何将图像,单选按钮的吧?

Here I am tryiong to put one image to the right of the first radio button, with no success. How do I put images to the right of the radio buttons?

对于一个按钮就可以把可绘制到顶部/左/右/它的底部。所以我想这可能工作了单选按钮以同样的方式。

For a button you can put drawables to the Top/right/left/bottom of it. So I thought it might work the same way for radiobutton.

看一看在Android开发者网站此链接

您是否尝试过这个?

更新

所以你的情况,删除ImageView的,并添加的android:drawableRight (或左/底/顶)在单选按钮

So in your case, remove the imageview and add android:drawableRight (or left/bottom/top) in your radiobuttons

<RadioButton
    android:drawableRight="@drawable/A2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="true"
    android:text="A"
    android:id="@+id/radio0"/>