2

There's a linear layout given with a TextView, which contains an image. I want to position the image on the left-bottom side of the TextView.

I did this with android:drawable:Left

 <TextView
        android:id="@+id/xmpp_chatlist_tv_partnerID_inc_Message"
        android:layout_width="match_parent"
        android:layout_height="80sp"
        android:padding="6dip"
        android:textColor="@color/black"
        android:background="@drawable/round_corners"
        android:layout_weight="0.125"
        android:drawableLeft="@drawable/xmpp_notation"
        android:drawablePadding="5dp"
        android:gravity="left">
    </TextView>

I also did this:

  textView_partnerID_inc.setCompoundDrawablesWithIntrinsicBounds(
            R.drawable.xmpp_notation, 0, 0, 0);

How to get the image shown on the left-bottom side?

Eclipse
  • 175
  • 1
  • 12

2 Answers2

2

Either you can use LinearLayout like this:

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

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text aligned bottom left"/>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:src="@drawable/apk_icon"
        android:layout_gravity="left"/>

</LinearLayout>

Or you can use a RelativeLayout like so:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text aligned bottom left"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"/>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:src="@drawable/apk_icon"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/label"/>

</RelativeLayout>

Or using a Drawable, you can do this by adding gravity top:

<TextView
    android:id="@+id/xmpp_chatlist_tv_partnerID_inc_Message"
    android:layout_width="match_parent"
    android:layout_height="80sp"
    android:padding="6dip"
    android:textColor="@color/black"
    android:background="@drawable/round_corners"
    android:layout_weight="0.125"
    android:drawableLeft="@drawable/xmpp_notation"
    android:drawablePadding="5dp"
    android:gravity="left|top">
</TextView>
Daniel
  • 2,355
  • 9
  • 23
  • 30
Aditi
  • 455
  • 4
  • 13
0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text aligned bottom left"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

than add the image

Francesco Taioli
  • 2,687
  • 1
  • 19
  • 34