Android 在不使用librery的情况下,如何在状态、焦点和正常状态下应用TextInputLayout的自定义形状
我想设计一个自定义圆角文本输入布局 正如我在下面展示的活动TextInputLayout的示例图像 我的xml代码是Android 在不使用librery的情况下,如何在状态、焦点和正常状态下应用TextInputLayout的自定义形状,android,widget,android-textinputlayout,material-components-android,material-components,Android,Widget,Android Textinputlayout,Material Components Android,Material Components,我想设计一个自定义圆角文本输入布局 正如我在下面展示的活动TextInputLayout的示例图像 我的xml代码是 <com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <com.google.andr
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/mobile_number"
android:inputType="number"
android:fontFamily="@font/montserrat_regular"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
它给我一个默认的TextInputLayout。我怎样才能得到我的观点。请帮我解决。
获取样式声明中的错误。
只需使用Widget.MaterialComponents.TextInputLayout.OutlineBox样式并应用自定义形状:
<com.google.android.material.textfield.TextInputLayout
style="@style/OutlinedRoundedBox"
...>
与:
如果您想在不使用第三个库的情况下实现设计。只需创建如下样式:
<style name="OutlinedRoundBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxBackgroundMode">outline</item>
<item name="boxCornerRadiusBottomEnd">32dp</item>
<item name="boxCornerRadiusBottomStart">32dp</item>
<item name="boxCornerRadiusTopEnd">32dp</item>
<item name="boxCornerRadiusTopStart">32dp</item>
<item name="android:paddingLeft">20dp</item>
</style>
长官,我的风格声明有错误。正如我在上面问题中显示的截图。请再次检查。非常感谢您的支持,先生。我的style.xml文件如下所示。概述32dp 32dp 32dp 32dp 32dp 20dp要解决您的问题,您必须使用1.1.0版。这在1.3.0版Android 11中对我不起作用
<style name="OutlinedRoundBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxBackgroundMode">outline</item>
<item name="boxCornerRadiusBottomEnd">32dp</item>
<item name="boxCornerRadiusBottomStart">32dp</item>
<item name="boxCornerRadiusTopEnd">32dp</item>
<item name="boxCornerRadiusTopStart">32dp</item>
<item name="android:paddingLeft">20dp</item>
</style>