I have an ImageView
as a child of a ViewGroup
that is part of a GridView
. The drawable of the ImageView
does not appear, however I can see the background color, and if I use the drawable in setBackgroundDrawable
instead, it is displayed. I've tried changing every property and calling invalidate()
but none have made the drawable appear.
The Log.i
prints
android.graphics.drawable.BitmapDrawable@407bd4c0
setImageResource(int)
doesn't work either.
I'm using Honeycomb.
public MyViewGroup(Context context) {
super(context);
myImageView = new ImageView(context);
myImageView.setBackgroundColor(Color.RED);
myImageView.setScaleType(ImageView.ScaleType.CENTER);
Drawable drawable = this.getResources().getDrawable(R.drawable.myimage);
myImageView.setImageDrawable(drawable);
Log.i("",drawable+"");
//myImageView.setImageResource(R.drawable.myimage);
addView(myImageView);
}
I omitted the onLayout code where I call setLeft()
setTop()
setRight()
and setBottom()
.
Any help is much appreciated. Thanks.
Update: Also doesn't work with android.R.drawable images. I'm stumped.