// 动态drawable样式
if (A) {
textView.setText("A");
textView.setBackgroundResource(R.drawable.xxx);
Drawable drawable = context.getResources().getDrawable(R.drawable.xxx);
drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());
textView.setCompoundDrawables(drawable, null, null, null);
} else {
textView.setText("B");
textView.setBackgroundResource(R.drawable.xxx);
Drawable drawable = context.getResources().getDrawable(
R.drawable.xxx);
drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());
textView.setCompoundDrawables(drawable, null, null, null);
}
Android中动态drawable样式
最新推荐文章于 2023-11-26 20:42:31 发布