动态改变按钮背景状态
很少用到 上次和六哥聊到。六哥有心 查了下 以下是DEMO
public static StateListDrawable setStateListDrawable(Context mActivity,
int up, int down) {
StateListDrawable stateListDrawable = new StateListDrawable();
BitmapDrawable db = new BitmapDrawable(mActivity.getResources(),
LoadImage.loadImage(mActivity.getResources(), down));
stateListDrawable.addState(new int[] { android.R.attr.state_pressed },
db);
db = new BitmapDrawable(mActivity.getResources(), LoadImage.loadImage(
mActivity.getResources(), up));
stateListDrawable.addState(new int[] {}, db);
return stateListDrawable;
}
本文介绍了一种使用StateListDrawable实现按钮背景动态切换的方法。通过不同的状态设置对应的背景图片,使得按钮能在按下和未按下状态间平滑过渡。
559

被折叠的 条评论
为什么被折叠?



