![android– 带有@null背景的图像按钮(透明)[复制],第1张 android– 带有@null背景的图像按钮(透明)[复制],第1张](/aiimages/android%E2%80%93+%E5%B8%A6%E6%9C%89%40null%E8%83%8C%E6%99%AF%E7%9A%84%E5%9B%BE%E5%83%8F%E6%8C%89%E9%92%AE%28%E9%80%8F%E6%98%8E%29%5B%E5%A4%8D%E5%88%B6%5D.png)
参见英文答案 > How to set image button backgroundimage for different state? 10个
我有一个带有透明度的图像源的图像按钮,但图像按钮的背景颜色是典型的灰色按钮颜色.
我想设置背景= @null,这很好.
但是,当我按下此图像按钮时,我看不到表示我按下按钮的颜色.
如果我在按下按钮时删除background = @null,请更改用户知道您按下的颜色.
我读到你可以创建一个带有3个图像的xml,指定按下按钮的时间,此正常情况以及何时聚焦.但我认为存在一种更容易的方法.
解决方法:
根据上述答案,使用选择器drawable(对于背景,而不是null)将默认状态设置为透明颜色:
* selector_with_transparency:*
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID" > <item androID:state_pressed="true" androID:drawable="@drawable/pressed" /> <item androID:drawable="@drawable/transparent" /></selector>按:
<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" > <solID androID:color="#0077cc" /></shape>透明:
<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" > <solID androID:color="#00000000"/></shape>然后为Imagebutton:
background = "@drawable/selector_with_transparency" 总结 以上是内存溢出为你收集整理的android – 带有@null背景的图像按钮(透明)[复制]全部内容,希望文章能够帮你解决android – 带有@null背景的图像按钮(透明)[复制]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)