我想在此处附上一对复选框和单选按钮:
...在矩形或“边界框”中,使其看起来像这样:
......当然,但不那么难看。如何以以下 XML 作为起点来做到这一点:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="hhs.app.SettingsActivity">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="@string/select_your_printer"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/ckbxNoPrinter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/no_printer" />
<CheckBox
android:id="@+id/ckbxZebraQL220"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/zebra_ql220" />
<Space
android:layout_width="match_parent"
android:layout_height="5dp" />
. . .
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radbtnBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/using_labels_black" />
<RadioButton
android:id="@+id/radbtnPlain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/using_plain_labels" />
</RadioGroup>
<Space
android:layout_width="match_parent"
android:layout_height="2dp" />
. . .
</LinearLayout>
</LinearLayout>
?
UPDATE
我尝试应用 Der Golem 的建议,如下所示:
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:layout_width="wrap_content">
<stroke
android:width="4dp"
android:color="#f000"
android:layout_width="wrap_content" />
<TextView
android:text="@string/after_fetching_palabra"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</shape>
</LinearLayout>
...但这没有任何作用(好的); TextView 只是作为测试,从一个简单的小部件开始。
注意:这是 LinearLayout 中的 LinearLayout。当我删除它时,一切都很好,但是有了它,布局甚至不会渲染。
UPATE 2
所以我认为我将形状放在 \res\drawable 文件夹中。但在 Droidio 中,它给了我四个,数一下,四个可绘制文件夹,即:
drawable-hdpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
我需要将xml放入each这些文件夹,或者我可以创建一个“通用/默认”普通旧“可绘制”文件夹并将其放在那里吗?