In the ApiDemos, there is a view example called Gallery1 which declares a custom style in attrs.xml, as such:
create a xml file and paste this below code and put in res->values folder
and then copy below code
TypedArray typedArray=this.obtainStyledAttributes(R.styleable.Gallery1);
int back=typedArray.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0);
typedArray.recycle();
and set in ur widget background i mean imageView.setBackgroundResource(back);