1

Which is the best way to achieve this. image view or canvas? 1)load random image from resources 2)on top the image load random text from strings 3)then save them as jpeg to share with other apps i have tried with text view with image background, but saving image is not possible.

 <CustomView
            android:id="@+id/view"`enter code here`
            android:layout_width="match_parent"
            android:layout_height="512dp" />
Danny RDX
  • 77
  • 1
  • 9

1 Answers1

1

you can convert your displayed view to bitmap using

public static Bitmap loadBitmapFromView(View v) {
    Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
    Canvas c = new Canvas(b);
    v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    v.draw(c);
    return b;
}

Now you can share this bitmap. check more details here Converting a view to Bitmap without displaying it in Android?

Vivart
  • 14,900
  • 6
  • 36
  • 74