Android填充左侧为TextView中的文本,左侧包含图像,右侧包含文本

时间:2012-09-15 00:57:58

标签: android user-interface

我有一个TextView,它包含左侧的图像和右侧的文本:

enter image description here

我想在垂直线和文本之间创建一个空格。

这是我的代码:

    <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" />

我该怎么做?

提前致谢。

更新

这是我在Drawable中使用的balloon_line

enter image description here

1 个答案:

答案 0 :(得分:15)

您是否尝试过使用android:drawablePadding

示例:在文本和左侧drawable之间添加5dp填充

<TextView
    android:id="@+id/locationDetailsTitleTextView"
    ...
    android:drawableLeft="@drawable/balloon_line" 
    android:drawablePadding="5dp"/>