下面列出了android.support.v4.app.ActivityCompat#getDrawable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void setCenterDrawableRight(int ResId) {
Drawable drawable = ActivityCompat.getDrawable(mContext, ResId);
//要加这句才能显示
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
centerView.setCompoundDrawables(null, null, drawable, null);
centerView.setClickable(true);
}
public void setRightDrawableRight(int ResId) {
Drawable drawable = ActivityCompat.getDrawable(mContext, ResId);
//要加这句才能显示
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
rightView.setCompoundDrawables(null, null, drawable, null);
rightView.setClickable(true);
}
public void setLeftDrawableRight(int ResId) {
Drawable drawable = ActivityCompat.getDrawable(mContext, ResId);
//要加这句才能显示
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
leftView.setCompoundDrawables(null, null, drawable, null);
leftView.setClickable(true);
}
public DividerGridItemDecoration(Context context) {
mDivider = ActivityCompat.getDrawable(context, R.drawable.divider_bg);
}