<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"/>
这是我的文本视图。我想将可绘制对象设置在此文本视图的左侧。但问题是,如果文本是多行的,则可绘制对象在文本视图中显示为中心垂直。
是否有任何选项可以在文本视图的左上角设置可绘制对象?
类似于@Avinash Kumar Singh 解决方案。如果您有一个小图像,它将高于第一行文本。
在这种情况下,您应该将图像以第一行居中。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:drawableStartCompat="@drawable/dot"
tool:drawableStart="@drawable/dot" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
tool:text="This is my textview. I want to set the drawable on left of this textview" />
</LinearLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)