Discussion:
Layout one horizontal line with two TextViews
DWischer
2009-10-01 12:53:07 UTC
Permalink
Hi,

i will go insane in a minute with this problem.
What i want to do is to design a layout, with one Textview on the left
oft the screen and on Textview on the right of the screen.
So that both fields grow to the center when a longer text is set.

My xmlfile:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<!-- First Row, only one element -->
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:text="check2" android:id="@+id/customerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>



<!-- Second Row, 2 Elements, one float left one float right -->
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView android:text="check2" android:id="@+id/StreetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />

<TextView android:text="check2" android:id="@+id/materialText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />

</LinearLayout>
</LinearLayout>

So the streetText should be left and the meterialText should be right.
I tried every constellation of gravity etc., but nothing worked.
Thanks for helping.

Regards,
Daniel
Stefan
2009-10-01 13:45:51 UTC
Permalink
Hi,

try this instead of your second LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView android:text="check2" android:id="@+id/
StreetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />

<TextView android:text="check2" android:id="@+id/
materialText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="right"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@id/StreetText"
android:layout_toRightOf="@id/StreetText"
/>

</RelativeLayout>
Stefan
2009-10-01 13:46:55 UTC
Permalink
Post by DWischer
<?xml version="1.0" encoding="utf-8"?>
without the xml tag of course.. and change the id/name of the
relativeLayout tag ;)

Loading...