How Can I Enclose Some Xml Elements In A Bounding Box?
Solution 1:
Use a vertical LinearLayout to enclose your CheckBoxes and another one to enclose your RadioButtons and assign them an xml drawable as the background (you could alternatively use a 9 patch, if you feel more comfortable with):
The two extra LinearLayouts are children of the outer container.
/res/drawable/box.xml
(self contained xml drawable):
<?xml version="1.0" encoding="utf-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"
><strokeandroid:width="4dp"android:color="#f000"
/></shape>
For reference: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
[EDIT]
Apply the xml drawable as a normal background:
This is just one of the two layous: the "CheckBox" one:
...
<LinearLayoutandroid:orientation="vertical"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/box"
><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:padding="5dip"android:text="@string/select_your_printer"android:textAppearance="?android:attr/textAppearanceMedium" /><CheckBoxandroid:id="@+id/ckbxNoPrinter"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@string/no_printer" /><CheckBoxandroid:id="@+id/ckbxZebraQL220"android:layout_width="fill_parent"android:layout_height="wrap_content"android:checked="true"android:text="@string/zebra_ql220" /></LinearLayout>
...
[EDIT 2]
Now a little digression. You asked for a simple square box and nothing else, so that's what I provided. BUT. In the link I provided is shown in details how you can (for instance) not only make the corners round, but also give your shape a different background color or even a color gradient. Just to name some interesting properties of the Shape Drawable.
Post a Comment for "How Can I Enclose Some Xml Elements In A Bounding Box?"