如何在 TextInputLayout 中垂直居中绘制?
How to centre drawable vertically in TextInputLayout?
我在 TextInputLayout 的左侧添加了一个可绘制对象(如下面的 TextInputEditText 所示),并想在其下方添加一些填充,使其在其父对象内垂直居中。是否有针对此的命令或解决方法?
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/contact_first_name_input_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="@string/contact_first_name"
android:layout_marginEnd="8dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/contactFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName|textCapWords"
android:drawableStart="@drawable/ic_person_black_24dp"
android:drawablePadding="8dp"
/>
在 TextInputLayout
中使用 app:startIconDrawable
属性添加可绘制对象:
<com.google.android.material.textfield.TextInputLayout
app:startIconDrawable="@drawable/..."
我在 TextInputLayout 的左侧添加了一个可绘制对象(如下面的 TextInputEditText 所示),并想在其下方添加一些填充,使其在其父对象内垂直居中。是否有针对此的命令或解决方法?
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/contact_first_name_input_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="@string/contact_first_name"
android:layout_marginEnd="8dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/contactFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName|textCapWords"
android:drawableStart="@drawable/ic_person_black_24dp"
android:drawablePadding="8dp"
/>
在 TextInputLayout
中使用 app:startIconDrawable
属性添加可绘制对象:
<com.google.android.material.textfield.TextInputLayout
app:startIconDrawable="@drawable/..."