1) create the attrs.xml file in the res> value folder.
2) Add a resource:
<declare-styleable name="Gallery1">
<attr name="android:galleryItemBackground" />
</declare-styleable>
3) Add the following code to your activity:
TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
int mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground, 0);
a.recycle();
4), then set the mGalleryItemBackgroundbackground of your view. You will get a border outside your view. For instance:
imageView.setBackgroundResource(mGalleryItemBackground);
source
share