I am using a custom view instead of a resource in my gallery. However the background of selected view is becoming black. The code for getView in the baseadapter is like this:-
public View getView(int position, View convertView, ViewGroup parent) {
MyView grpView = new MyView(context);
grpView.setLayoutParams(new Gallery.LayoutParams(105,105));
grpView.setScaleType(ImageView.ScaleType.FIT_XY);
grpView.setBackgroundResource(mGalleryItemBackground);
return grpView;
}
I want the selected view to be nicely framed like it happens when you use a xml resource like in API documentation:-
imageView.setImageResource(mImageIds[position]);
Any help appreciated.
Resolved by
Drawing the background color in OnDraw of MyView. This removed the black background.
Again drew a light grey border for only selected view in OnDraw of MyView. This gave a similar effect to what happens with an xml resource.