4
我爲Android 2.2構建了這個版本設置android:背景正在搞亂我的單選按鈕的文本
這是我的代碼。 java是由eclipse生成的。我改變了xml。
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中
<?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>
雖然與單選按鈕我開始做一個非常簡單的應用試驗。它看起來像這樣:
*水平×垂直
沒有很好的理由,我想我會改變背景顏色。我通過改變RadioGroup元素的背景開始,一切都按照預期工作。然後,只是爲了好玩,但我會改變組中單選按鈕之一的背景。這可以在上面的main.xml中看到。這樣做後,我注意到了單選按鈕的文字現在覆蓋的單選按鈕,頁面現在看起來是這樣的:
* rizontal *垂直
除了可以仍然有種看到水平的「豪」,他們只是由單選按鈕覆蓋
這是預期的行爲?
我會......絕對不會說這種預期的行爲。自己嘗試一下,我唯一能想到的就是他們使用了一個有限內容區域的空NinePatch ......但這似乎極其不可能。 – kcoppock 2010-12-05 07:05:23
剛剛發現了同樣的事情!嘆。你有沒有找到任何其他答案或解決方法? – 2012-11-06 18:15:34