shankey
shankey

Reputation: 333

How to place image button to extreme right?

I have horinzontal linear layout which contans one TextView and one ImageView. The length of text is not fix and I want to place the Image to the extreme right. I tried android:layout_alignParentRight="true" then android:layout_marginRight="0dip" but nothing works properly. please Help..!!

Upvotes: 2

Views: 766

Answers (1)

kalpana c
kalpana c

Reputation: 2739

You can set android:layout_weight="1" in TextView no need to write android:layout_alignParentRight="true"

example

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="horizontal" >


    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icn_listarrow" />

Upvotes: 4

Related Questions