如何在TextInputLayout中垂直绘制图形居中?

问题描述 投票:0回答:1

我已经在TextInputLayout的左侧添加了一个drawable(如下面的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"
                    />
android material-design android-textinputlayout material-components material-components-android
1个回答
0
投票

app:startIconDrawable中使用TextInputLayout属性添加可绘制对象:

<com.google.android.material.textfield.TextInputLayout
       app:startIconDrawable="@drawable/..."

enter image description here enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.