3

I have a TextView which contains an image on the left side and text on the right side:

enter image description here

I would like to create a space between the vertical line and the text.

This is my code:

<TextView
    android:id="@+id/locationDetailsTitleTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/map_activity_location_details_dialog_title"
    android:textColor="@color/actionbar_title_color"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:drawableLeft="@drawable/balloon_line" />

How can I do this?

UPDATE

This is the Drawable I use in balloon_line:

enter image description here

Jason Aller
  • 3,391
  • 28
  • 37
  • 36
Jorge Gil
  • 3,881
  • 3
  • 33
  • 54
  • just wondering, what `Drawable` did u use for your balloon_line? – Jonathan Lin Jul 11 '13 at 07:56
  • That `Drawable`is pretty simple. It is a transparent square with the right margin representing the blue line you see next to the text. I will left you an update with the `Drawable`. – Jorge Gil Jul 11 '13 at 18:30
  • thanks. I ended up using a `` with a colored background, since I didn't want to deal with a tiny image :) (http://stackoverflow.com/a/2659038/1161743) – Jonathan Lin Jul 12 '13 at 01:53

2 Answers2

15

Have you tried using android:drawablePadding?

Example: Adding a 5dp padding between the text and the left-side drawable

<TextView
    android:id="@+id/locationDetailsTitleTextView"
    ...
    android:drawableLeft="@drawable/balloon_line" 
    android:drawablePadding="5dp"/>
Ole
  • 7,621
  • 2
  • 27
  • 34
2

use this tag in your textview android:drawablePadding="5dp"

Narendra
  • 880
  • 1
  • 11
  • 11