添加阴影按钮的android [英] Add shadow to button in android
问题描述
我想在图像按钮添加某种影子上点击。是否可能,如何。
I'm trying to add some kind of shadow over image button on click. Is it possible and how.
所以我有按钮,我希望当我点击它,它看起来会推。因此,我创建新的XML这样的:
So i have button and i wished it would look pushed when i click it. So i created new xml like that:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@color/btn_pushed"
/>
<item
android:drawable="@drawable/btn" />
</selector>
确定它工作正常,但我有像50按钮和我必须做出新的图像为他们所有。这是一个很大的工作,是有可能只是添加一些阴影了呢?或东西,这样它看起来推?
Ok it works fine, but i have like 50 buttons and i have to make new image for all of them. That's a lot of work, is it possible to just add some kind of shadow over it? Or something so that it will look pushed?
推荐答案
所以,我找到了一个解决方案,我在这里添加了功能的读者。诀窍是使用。
我在这里找到了答案 http://belencruz.com/2012 / 12 /四舍五入按钮与阴影,在安卓/
现在我的code:
So i found a solution and i add it here for feature readers. The trick is to use . I found the answer here http://belencruz.com/2012/12/rounded-button-with-shadow-in-android/ My code now:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:state_enabled="true"
>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn" />
<item android:drawable="@color/transparent"/>
</layer-list>
</item>
<item
android:drawable="@drawable/btn" />
</selector>
作品真的不错!
这篇关于添加阴影按钮的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!