我无法更改图像按钮的背景图片。这是我当前尝试使用的代码:
然而,似乎是将新图像放在旧图像的顶部,导致我有两个图像重叠在一起。有人知道为什么会这样吗?
ImageButton imgButton = (ImageButton) findViewById(R.id.showSportsButton);
imgButton.setBackgroundResource(R.drawable.tab2_selected);
然而,似乎是将新图像放在旧图像的顶部,导致我有两个图像重叠在一起。有人知道为什么会这样吗?
ImageView
继承的.setImageResource
方法。 - zaplplease add imgButton.setImageResource(null); imgButton.setImageResource(R.drawable. tab2_selected);
- dipali