0

I need to add a drawable inside my textview and makes it take the same height as the text.

My xml :

...<LinearLayout
        android:id="@+id/line6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tableLayoutId">

        <TextView
            android:id="@+id/label10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingEnd="2dp"
            android:paddingRight="2dp"
            android:drawableRight="@drawable/greenarrowup"
            android:drawableEnd="@drawable/greenarrowup"
            /> ...

What I'm getting : Actual result

What I want : desired result

I've tried using imageView to get the desired result but didn't make it, can someone help me please ?
Thank you.

hereForLearing
  • 1,209
  • 1
  • 15
  • 33
  • Interesting question. See [this question and answers](https://stackoverflow.com/questions/9168021/compounddrawable-size). – Cheticamp Jul 02 '17 at 01:45

2 Answers2

0

You should set the horizontal orientation of the linear layout and use the imageview like this :

<LinearLayout
        android:id="@+id/line6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_below="@+id/tableLayoutId">

        <TextView
            android:id="@+id/label10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingEnd="2dp"
            android:paddingRight="2dp"
            /> 

        <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/greenarrowup" />


        </LinearLayout>
Karim
  • 322
  • 1
  • 10
0

Add certain height on textview and set gravity to be vertically centered

G Singh
  • 156
  • 4