我在gridview中显示图像和文本.即每个项目由一个图像和一个文本组成.它工作正常.但我想知道如何在android中分别设置每个gridview项的边框.
解决方法:
1)在res> value文件夹下创建一个attrs.xml.
2)添加资源:
3)在您的相应活动中添加以下代码:
TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
int mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground, 0);
a.recycle();
4)然后将mGalleryItemBackground设置为视图的背景.您将在视图之外获得边框.
例如:
imageView.setBackgroundResource(mGalleryItemBackground);
标签:android,gridview,border
来源: https://codeday.me/bug/20190730/1579322.html