开发者

Android: Is it possible to dynamically change the border color of a EditText?

开发者 https://www.devze.com 2022-12-28 06:40 出处:网络
I would like to change the Orange border around a EditText. Like when the input is valid, I want it to become green.

I would like to change the Orange border around a EditText. Like when the input is valid, I want it to become green.

alt text http://developer.android.com/guide/tutorials/views/images/hello-relativelayout.png

However I do not see开发者_JAVA百科m to find a method to do this. Is it possible?


It's not possible to change the orange border easily because it's actually a 9-patch - that is, the entire border + white background is a 9-patch that Android uses by default. It uses the android:background attribute to set it, too.

It would be possible to acquire a copy of the 9-patch (it will be in your SDK), edit the color to make it green, then in code configure it so that your 9-patch is set as the background of the EditText when the input is valid.

0

精彩评论

暂无评论...
验证码 换一张
取 消