android输入框样式,android-如何在styles.xml中设置TextInputEditText的样式

在Android中,可以通过在应用程序主题中设置`textInputStyle`和`editTextStyle`来全局改变TextInputLayout和TextInputEditText的样式。例如,可以设置字体、颜色等属性,以实现提示文本和输入文本的自定义样式。这将影响应用内的所有 TextInputLayout 和 TextInputEditText组件。
摘要由CSDN通过智能技术生成

我在注册屏幕上使用TextInputEditText.我可以设置浮动标签的样式.我想使用样式在TextInputEditText的提示和文本上设置自定义字体.有谁知道这是怎么回事?

android:id="@+id/til_registration_name"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginTop="16dp"

android:paddingEnd="@dimen/default_view_padding_right_8dp"

android:paddingStart="@dimen/default_view_padding_left_8dp"

android:textColorHint="@color/colorSecondaryText"

app:hintTextAppearance="@style/AppTheme.InputLayoutStyle"

app:layout_constraintTop_toBottomOf="@id/textview_registration_title">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/registration_name"

android:imeOptions="actionNext"

android:singleLine="true"

android:textColor="@color/colorPrimaryText" />

styles.xml

@color/colorPrimary

@font/lato_light

@color/colorPrimary

@color/colorPrimaryDark

@color/colorAccent

@style/DrawerArrowStyle

@style/AppTheme.TextView

@style/AppTheme.Button

我想为整个应用程序设置样式.

解决方法:

旧问题,但值得回答.

只需在应用程序主题中设置“ textInputStyle”以设置TextInputLayouts的样式,并设置“ editTextStyle”以设置TextInputEditTexts的样式.

@color/colorPrimary

@color/colorPrimaryDark

@color/colorAccent

@style/DrawerArrowStyle

@style/AppTheme.TextView

@style/AppTheme.Button

@style/MyCustomTextInputStyle

@style/MyCustomEditTextStyle

@color/colorSecondaryText

@style/any_style_you_may_want"

@color/colorPrimary

@font/lato_light

这会将相同的样式应用于应用程序中的所有TextInputLayout和TextInputEditText.

标签:android

来源: https://codeday.me/bug/20191025/1930169.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值