Android ColorDrawable不会在其边界上绘制
我正在尝试将ColorDrawable设置为backgroundDrawable可查看的边界,但它无法正常工作,请使用以下代码:Android ColorDrawable不会在其边界上绘制,android,android-layout,Android,Android Layout,我正在尝试将ColorDrawable设置为backgroundDrawable可查看的边界,但它无法正常工作,请使用以下代码: ColorDrawable d = new ColorDrawable(getContext().getResources() .getColor(R.color.red)); d.setBounds(0, 0, 20, 20); convertView.setBackgroundDrawable(d); 结果是convertView背景在此处被红
ColorDrawable d = new ColorDrawable(getContext().getResources()
.getColor(R.color.red));
d.setBounds(0, 0, 20, 20);
convertView.setBackgroundDrawable(d);
结果是convertView背景在此处被红色填充
谢谢。好的,所以当使用可绘制作为视图背景时,视图的边界会随着视图的布局而改变。因此,有了严格的界限,我需要扩展Drawable,并为其界限使用私有Rect。您的具体要求是什么?