Hi,

here I have a part of my layout, where I want to position a checkbox
to the right of the screen while it with two lines of text. I was
trying to mimic the look of the layout on the settings pages in the
emulator.
Here is the layout XML:

<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="4dp">
        <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="2dp">
                <TextView
                        android:text="Use colored text"
                        android:textSize="18sp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                </TextView>
                <TextView
                        android:text="Check to output colored text"
                        android:textSize="12sp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                </TextView>
        </LinearLayout>
        <LinearLayout
                android:orientation="vertical"
                android:gravity="right"
                android:layout_gravity="right"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="2dp">
                <CheckBox
                        android:id="@+id/check"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                </CheckBox>
        </LinearLayout>
</LinearLayout>

Now this works fine, but I was wondering why I need to wrap the
checkbox in another LinearLayout to actually get it to stick to the
right side. If I would remove the LinearLayout that's wrapping the
checkbox, it wouldn't be at the right side of the screen, even if I
would put gravity="right" in the checkbox properties. Any idea why? Or
any suggestion on how to create this layout more efficiently? Thank in
advance!


Cheers, Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to