Android更改图像按钮背景 [英] android change image button background
本文介绍了Android更改图像按钮背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法更改图像按钮的背景图像.这是我当前尝试使用的代码:
I cannot seem to change the background image of my image button. Heres the code i'm currently trying to use:
ImageButton imgButton = (ImageButton) findViewById(R.id.showSportsButton);
imgButton.setBackgroundResource(R.drawable.tab2_selected);
但是,这似乎是将新图像放置在旧图像之上,使我有2张彼此重叠的图像.
However this seem to be placing the new image on top of the old image leaving me with 2 images overlapping each other.
有人知道这是为什么吗?
Does anyone know why this is??
推荐答案
要解决此问题,您应该实现
For solving this question you should implement
imgButton.setImageResource(R.drawable. tab2_selected);
这篇关于Android更改图像按钮背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文