How to apply shadow color to Android EditText when focused?
I have an EditText control in my application and when it is focused (i.e. I'm ready to enter something) I want to apply shadow color to it. How can I do this?
Thanks, @naga开发者_运维百科raju.
You can use the Selector tag like Follows: Create a New xml file and place it in your drawable folder and name it as shadow_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/ask_footer"/>
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/askfooter_hover" />
<item android:drawable="@drawable/ask_footer" />
</selector>
And then go to that xml in which your EditText is declared: And write one attribute in editText
android:background="@drawable/shadow_color" and you are done.
Use a selector for your background drawable and create your own nine patches.
does shadow color mean you want a shadow theme background for your view??
then, assuming that you are using xml layout,the GU interface version shown on eclipse allows you to select a particular theme for your view,which i think is what you want.
if you want to put it manually, you must mention it in the android manifest
eg.
<activity android:name=".activity_name here"android:theme="@android:style/Theme.Dialog">//there are a handful of effects provided by SDK
</activity>
i suggest the graphical user interface method,its easy and you can see the effect as you select the theme
You can also check whether your EditText isFoucsed or not. And if true so change its background image to shadow like image.
精彩评论