android右上角没有视图选择,android – 所有Activity视图都没有选择主题

我有这个自定义样式:

@color/colorPrimary

@color/colorPrimaryDark

@color/colorAccent

@font/book_family

我通过在清单中添加以下内容,将此新样式作为主题应用于我的一个活动:

...

android:theme="@style/AppTheme.AppText"/>

...

结果不是我的预期.只有少数几个视图选择了自定义样式.下图显示了两个视图.第一个FIELD ONE没关系. FIELD TWO字段不会提取样式.

c0ebc1a05b3a2b7a99a453b991b78122.png

以下是这两个字段的定义:

android:id="@+id/til_email"

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:id="@+id/email"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_email"

android:inputType="number"

android:imeOptions="actionNext"

android:maxLines="1"

android:singleLine="true" />

android:id="@+id/til_password"

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_password"

android:imeActionId="6"

android:imeActionLabel="@string/action_sign_in_short"

android:imeOptions="actionUnspecified"

android:inputType="numberPassword"

android:maxLines="1"

android:singleLine="true" />

请问,任何想法?

解决方法:

似乎主题不适用于密码字段,可能出于安全原因.但我找到了解决密码字段样式的工作.您只需要为自定义样式添加另外两个属性:

@font/book_family

@color/colorAccent

14sp

然后在TextInputLayout上使用app:hintTextAppearance.您的密码字段如下所示:

android:id="@+id/til_password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:hintTextAppearance="@style/AppTheme.AppText">

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_password"

android:imeActionId="6"

android:imeActionLabel="@string/action_sign_in_short"

android:imeOptions="actionUnspecified"

android:inputType="numberPassword"

android:maxLines="1"

android:singleLine="true" />

说明:如文档中所述,hintTextAppearance:

Sets the hint text color, size, style from the specified

TextAppearance resource.

现在,当您按原样使用样式时,它只会更改font-family,但将textSize保持在8sp,将textColor保持为黑色.这就是我将这两个属性添加到您的自定义样式的原因.

标签:android,view,themes

来源: https://codeday.me/bug/20190522/1153375.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值