android edittext外观,自定义 TextInputLayout 的外观

本文介绍了如何在Android中通过styles.xml文件定义自定义样式,以改变TextInputLayout及其内嵌EditText的外观。示例展示了如何定制提示文字的样式、设置强调色,从而影响EditText的基线颜色和浮动提示文本的颜色。通过指定主题,可以将这些样式应用到布局文件中的TextInputLayout和EditText组件。
摘要由CSDN通过智能技术生成

你可以通过在 styles.xml 中定义自定义样式来自定义 TextInputLayout 及其嵌入式 EditText 的外观。定义的样式可以作为样式或主题添加到 TextInputLayout。

自定义提示外观的示例:

styles.xml:

@color/black

@color/indigo

@color/pink

要应用样式,请按如下方式更新 TextInputLayout 和 EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:hintTextAppearance="@style/MyHintStyle">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/Title"

android:theme="@style/MyEditText" />

自定义 TextInputLayout 的强调色的示例。重音颜色会影响 EditText 的基线颜色和浮动提示文本的文本颜色:

styles.xml:

@color/primary

布局文件:

android:id="@+id/textInputLayout_password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/TextInputLayoutWithPrimaryColor">

android:id="@+id/textInputEditText_password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/login_hint_password"

android:inputType="textPassword" />

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值