设置机器人:背景搞乱了文本我单选按钮机器人、单选、按钮、文本

2023-09-06 04:03:20 作者:偷吻月亮.

我建立了这个为Android 2.2

I built this for Android 2.2

下面是我的code。该Java是Eclipse生成。该XML我变了。

Here is my code. The java is generated by eclipse. The xml I changed.

package foo.bar.radiobuttontest;

import android.app.Activity;
import android.os.Bundle;
import foo.bar.radiobuttontest.R;

public class rbt extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

这是我的RES /布局/ main.xml中

here is my res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <RadioGroup
      android:id="@+id/orientation"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:padding="5px">
        <RadioButton
            android:id="@+id/horizontal"
            android:background="#aa0000"
            android:text="horizontal"
        />
        <RadioButton
            android:id="@+id/vertical"
            android:text="vertical"
        />
    </RadioGroup>
</LinearLayout>

虽然有单选按钮我开始做一个非常简单的应用试验。它看起来是这样的:

While experimenting with radiobuttons I started making a very simple app. It looks like this:

*水平*垂直

有关没有很好的理由,我想我会改变背景颜色。我开始通过改变RadioGroup中元素的背景,一切都正如预期。然后,只是为了好玩我,虽然我会改变只有一个组中的单选按钮的背景。这可以main.xml中以上可以看出。这样做后,我注意到了单选按钮的文本现在覆盖的单选按钮,页面现在看起来是这样的:

For no good reason I thought I would change the background color. I started by changing the background of the RadioGroup element, everything worked just as expected. Then just for fun I though I would change the background of only one of the radio buttons in the group. This can be seen in main.xml above. After doing this I noticed the text of the radiobutton is now covered by the radiobutton, the page now looks something like:

* rizontal *垂直

*rizontal * vertical

除非你仍然可以那种看到'豪'的水平,他们只是覆盖了单选按钮

Except you can still kind of see the 'ho' from horizontal they are just covered by the radiobutton

这是预期的行为?

推荐答案

我一直在寻找了一下,我发现,什么@kcoppock建议是正确的。 Here你会发现单选按钮的风格,和this是引用的背景图片:

I've been searching a bit and I've found that what @kcoppock proposed was right. Here you find radio button style, and this is the referenced background image:

这是一个九补丁的内容区域不包含无线领域。我想也可以从这一形象开始做一个自定义背景。

It's a nine-patch whose content area excludes the "radio" area. I guess one could start from this image to make a custom background.