我正在为EditText使用自定义xml文件来更改其外观。我尝试设置布局边距,填充,并将其设置为自定义宽度,但没有任何改变。
这是editText的xml:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/myEditTextId"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:gravity="center_horizontal"
android:inputType="textNoSuggestions"
android:textCursorDrawable="@drawable/dark_cursor"
tools:ignore="Autofill,LabelFor" />
这是Alertdialog,我正在使用EditXML的自定义xml文件来更改其外观。我尝试设置布局边距,填充并将其设置为自定义宽度,但没有任何改变...
尝试创建自定义图形并将其设置为EditText的背景
简单的解决方案,将使您的UI更加灵活。首先将您的Edittext
设为background="@null"
。然后为Edittext
画一个黑色下划线。在这里,您可以通过增加或减少当前2px
的高度值来增加或减少黑线的粗细。您可以通过增加或减少开始和结束边距来缩短或延长它。您也可以调整EditText
的大小。您现在可以使用边距,填充,自定义高度,自定义宽度等进行的所有操作。