Saturday, 17 August 2013

Android: Two columns (50% to 50%)

Android: Two columns (50% to 50%)

I am newbie to Android development (in fact I have downloaded ADK today)
and I want to create simple setting page with two columns. In first column
should be the text and in second column should be button/slider/etc.
My problem is that when I use LinearLayout, only FULL WIDTH TEXT is
visible. Columns are shown "outside" of screen on the right side of text.
This is how the screen should look like.
/-----------------\
| FULL WIDTH TEXT |
| |
| Column1 Column2 |
| Column1 Column2 |
\-----------------/
There is content of my XML file:
<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"
tools:context=".MainActivity"
android:weightSum="2"
android:orientation="horizontal"
>
<TextView
android:id="@+id/textview_settings_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_hint" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:visibility="visible" >
<CheckBox
android:id="@+id/checkbox_motion_sensor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/checkbox_motion_sensor" />
<CheckBox
android:id="@+id/checkbox_light_sensor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/checkbox_light_sensor" />
<CheckBox
android:id="@+id/checkbox_shake_sensor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/checkbox_shake_sensor" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:visibility="visible" >
<SeekBar
android:id="@+id/seekbar_motion_sensor_sensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
How can I set the inner layouts to be drawn on bottom of TextView? Thank
you for your help.

No comments:

Post a Comment