我以编程方式设置ImageButton的按下状态。Android ImageButton按下状态不变
问题是当我按下它时,状态根本没有改变。我尝试使用state_focused
和其他一些,但按钮并没有改变。你知道为什么我的ImageButton在按下时没有改变它的图像吗?
_pauseButton = new ImageButton(_context);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] {},
getResources().getDrawable(R.drawable.pause));
stateListDrawable.addState(new int[] {android.R.attr.state_pressed},
getResources().getDrawable(R.drawable.pausepressed));
_pauseButton.setImageDrawable(stateListDrawable);
默认状态图像确实显示正确,但按下时没有变化。
感谢,我会尝试这个时候,我回来办公室 – Aggressor
设置按下状态不遗憾的是工作 – Aggressor