Reputation: 445
I still didn't find a solution how to do that in XML I want my textview to be align to the left, and my imageview to be align to the right, here is the code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_height="wrap_content"
android:text="Vibration"
android:layout_width="wrap_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
Is there any way to do that ?
Upvotes: 1
Views: 4535
Reputation: 1322
I modified your layout, and this code works for me, hope this would also work for you.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tr1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_height="fill_parent"
android:text="Vibration"
android:paddingTop="10dp"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_weight="70" />
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:contentDescription="contentDescription"
android:layout_weight="30"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
Upvotes: 0
Reputation: 1595
I achieved it by using,
android:gravity="left"
android:paddingLeft="50dp"
Hope it help!
Upvotes: 1
Reputation: 544
shouldnt it be:
android:layout_alignParentLeft="true" /// for the textbox
android:layout_alignParentRight="true" /// for the imageview . Try this
Upvotes: 0
Reputation: 28179
Try changing your TableRow
to the following:
<TableRow
android:id="@+id/tr1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Vibration"
android:gravity="left" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:gravity="right"
android:src="@drawable/ic_launcher" />
</TableRow>
Upvotes: 1