我如何使AlertDialog中EditText上的黑线变小?

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

This is the alertdialog

我正在为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文件来更改其外观。我尝试设置布局边距,填充并将其设置为自定义宽度,但没有任何改变...

android kotlin android-alertdialog
2个回答
0
投票

尝试创建自定义图形并将其设置为EditText的背景


0
投票

简单的解决方案,将使您的UI更加灵活。首先将您的Edittext设为background="@null"。然后为Edittext画一个黑色下划线。在这里,您可以通过增加或减少当前2px的高度值来增加或减少黑线的粗细。您可以通过增加或减少开始和结束边距来缩短或延长它。您也可以调整EditText的大小。您现在可以使用边距,填充,自定义高度,自定义宽度等进行的所有操作。

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