如何变灰意见。特别是一个EditText? [英] How to grey out Views. Specifically an EditText?

查看:384
本文介绍了如何变灰意见。特别是一个EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿家伙
首先感谢阅读这一点。
我无法找到一种方法来改变我的EditText当我失去焦点吧。
我想它是灰色的,当发生这种情况,但我不希望它被禁用,因为用户可以触摸它,编辑文本后。

Hey guy's First of all thanks for reading this. I'm having trouble to find a way to change my EditText when I loose focus to it. I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.

有人吗?

您好!

推荐答案

可以的设置不同的颜色文本基于一个的 OnFocusChangeListener

另一种选择是设置在XML样式。详情请参见这个问题:安卓转变作风时集中

Another option is to set a style in xml. See this question for details: Android: change style when focused

要更改不透明度,使用 setAlpha 。在这个答案我展示它如何做到这一点在动画:<一href=\"http://stackoverflow.com/questions/6085912/two-questions-about-custom-app-uis-and-alphaanimation/6086125#6086125\">Two有关自定义应用程序的用户界面的和AlphaAnimation 问题

To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation

这篇关于如何变灰意见。特别是一个EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆