设置背景色及以上的ImageButton背景设置的图像 - Android电子 [英] set background color and set image over background in ImageButton - Android
本文介绍了设置背景色及以上的ImageButton背景设置的图像 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要设置在这样的背景下背景颜色和图像,我该怎么办呢?是necesary有透明度的形象呢?我需要控制的状态太:pressed,专注
I need to set a background color and an image over that background, how can i do it? Is necesary the image to have transparency? I need to control states too: pressed, focused.
任何帮助将非常感激。
推荐答案
创建ImageView的(使用透明的PNG为你的src图片):
的 RES /布局/ yourlayout.xml 的
<ImageView
android:layout_width=:"wrap_content"
android:layout_height=:"wrap_content"
android:background="@drawable/colorstates"
android:src="@drawable/image" />
的 RES /绘制/ colorstates.xml 的
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/regular"
android:state_checked="true"
android:state_pressed="true" />
<item
android:drawable="@drawable/pressed"
android:state_pressed="true" />
<item
android:drawable="@drawable/pressed"
android:state_checked="true" />
<item
android:drawable="@drawable/regular" />
</selector>
这篇关于设置背景色及以上的ImageButton背景设置的图像 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文