Abd*_*dir 1 android widget android-textinputlayout material-components material-components-android
我想设计一个自定义圆角 TextInputLayout 正如我展示的活动 TextInputLayout 的示例图像
以下
我的 xml 代码是
<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>
Run Code Online (Sandbox Code Playgroud)
只需使用Widget.MaterialComponents.TextInputLayout.OutlinedBox样式并应用自定义形状:
<com.google.android.material.textfield.TextInputLayout
style="@style/OutlinedRoundedBox"
...>
Run Code Online (Sandbox Code Playgroud)
和:
<style name="OutlinedRoundedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="shapeAppearanceOverlay">
@style/ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded
</item>
</style>
<style name="ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">32dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2281 次 |
| 最近记录: |