I've got a fragment with GridView and each element of GridView have and ImageView and TextView. I want to create and image with the ImageView and TextView, is it possible?
This is the code for the element of GridView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants" >
<ImageView
android:id="@+id/imgGrid"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="5dp"
android:scaleType="centerInside"
android:src="@drawable/myImg" />
<TextView
android:id="@+id/nameGrid"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@+id/imgGrid"
android:layout_centerHorizontal="true"
android:background="@drawable/border_blue"
android:gravity="center"
android:text="My image"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
I want that each element of GridView will be an image like this:
I do the rounded image with the following code:
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, Context mContext) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int radius = Math.min(h / 2, w / 2);
Bitmap output = Bitmap.createBitmap(w + 8, h + 8, Bitmap.Config.ARGB_8888);
Paint p = new Paint();
p.setAntiAlias(true);
Canvas c = new Canvas(output);
c.drawARGB(0, 0, 0, 0);
p.setStyle(Paint.Style.FILL);
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
c.drawBitmap(bitmap, 4, 4, p);
p.setXfermode(null);
p.setStyle(Paint.Style.STROKE);
p.setColor(mContext.getResources().getColor(R.color.myPrimaryColor));
p.setStrokeWidth(4);
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
return output;
}
Then I need to link the ImageView and TextView in one image to set the rounded image of the element in GridView. What can I do to achieve this effect?
Thanks in advance.