-1

I want to create a download button so that users can download the contents of the ImageView and TextViews (which is on top of the ImageView) as an image file and save it in the device storage.

Here is the code block:

    <ImageButton
    android:id="@+id/back_btn"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@mipmap/ic_back"
    android:layout_marginTop="20dp"/>

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/quotes_background"
        android:layout_centerInParent="true"/>

    <TextView
        android:id="@+id/quoteBody"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="20sp"
        android:typeface="monospace"
        android:textColor="@color/white"
        android:gravity="center"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"/>

    <TextView
        android:id="@+id/author"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="25sp"
        android:layout_below="@id/quoteBody"
        android:textColor="@color/white"
        android:layout_marginTop="20px"
        android:gravity="center"/>

I just want to select the ImageView and the two TextViews and download them as an image (PNG). Any help will be appreciated.

Thank You.

Kunday
  • 3
  • 3
  • Your question isn't clear. You don't download `TextView` and `ImageView`, those are Android components. You have to download the content and set it on the Views on runtime. – JonZarate Oct 23 '17 at 10:07
  • @JonZarate I apologize. I might have framed the question wrong. What I aim to do is create a download button for the user. Using which the user can download the contents of the TextView and ImageView together as an image file. – Kunday Oct 23 '17 at 11:00

1 Answers1

0

What you probably want is to save a Bitmap of what you see on the screen. See this answer.

etan
  • 573
  • 5
  • 14
  • Thank you for showing me the right path. I was able to encase the Views inside a Framelayout and convert the Framelayout into a Bitmap. Then I saved the Bitmap as a PNG file. – Kunday Oct 24 '17 at 08:14