<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/padding_small_6"
android:includeFontPadding="false"
android:text="@string/forgot_password_hint"
android:drawableStart="@drawable/ic_edit"
android:textSize="@dimen/text_size_medium_14"/>
这是我的 TextView 。我想在此 TextView 的左侧设置可绘制对象。但问题是,如果文本是多行的,那么 drawable 会在 TextView 中显示为居中垂直。
是否有任何选项可以在 TextView 的左上角设置可绘制对象?
最佳答案
No, their is no any direct option to set drawable on Top-Left of the textview.
但是您可以创建一些自定义设计来实现此目的。将您的 TextView
替换为以下代码
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_edit" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:text="@string/forgot_password_hint"
android:textSize="@dimen/text_size_medium_14"/>
</LinearLayout>
关于android - 如何在 TextView 的左上角设置可绘制对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59115360/