Android 在 TextView 中向左填充文本,其中包含左侧的图像和右侧的文本

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

我该怎么做?

更新

这是我在 balloon_line 中使用的 Drawable:

enter image description here

最佳答案

您是否尝试过使用 android:drawablePadding

示例:在文本和左侧可绘制对象之间添加 5dp 的内边距

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

关于Android 在 TextView 中向左填充文本,其中包含左侧的图像和右侧的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12433676/

相关文章:

android - 无法获取 'play-services-location/maven-metadata.xml' 。从服务器 : Bad Gateway 收到状态码 502

android - 打开 Android 设备监视器时缺少约束

android - 在 android studio 中膨胀 ConstraintLayout 时出错

python - cx_freeze 中的 TCL_LIBRARY

java - 在没有最终修饰符的情况下更改按钮颜色onclick

java - 错误 : must implement OnFragmentInteractionListener

java - 包含 Apache POI 时的 Android 重复类错误

java - 将 Actionlistener 类型转换为整数 java

python - 如何替换基于 Tkinter 的 Python GUI 应用程序中的 Python Logo ?

c++ - 应用GUI开发平台