Gridview image border

I use gridview to display a group of images from xml using xml parsing, now I want to display a frame around each image in gridview. All images should display an outline frame on the image in a gridview. How to set border for each image in gridview?

+4
source share
3 answers

Have you tried to set the resource / color for the image as a background on the grid, and also specify a residence permit for the same?

0
source

Check out this tutorial:

http://www.firstdroid.com/2011/02/06/android-tutorial-gridview-with-icon-and-text/

In the grid.item.xml file and add the background:

If the image size is fixed, add a transparent .png background with a border. If the image is resized, you need to use a 9-layer image.

BR, Adrian.

0
source

I used this layout in my project, you can use this hope, it helps.

//Border drawable xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@android:color/transparent" /> <stroke android:width="0.7dip" android:color="#808080"/> </shape> //Layout xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/grid_selector" android:orientation="vertical" android:padding="5dp" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:background="@drawable/border" android:orientation="vertical" android:padding="3dp" > <ImageView android:id="@+id/grid_image" android:layout_width="100dp" android:layout_height="110dp" android:layout_gravity="center_horizontal" android:layout_margin="1dp" android:contentDescription="@string/gridview_image_desc" android:scaleType="fitXY" /> </LinearLayout> <TextView android:id="@+id/grid_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ems="6" android:gravity="center_vertical|center_horizontal" android:maxLines="3" android:textColor="#808080" android:textSize="13sp" > </TextView> <TextView android:id="@+id/grid_text2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:textColor="#ff0000" android:textSize="15sp" android:textStyle="bold" > </TextView> </LinearLayout> 
0
source

All Articles