简体   繁体   English

有没有办法只选择 ImageView 和 Textview 的内容并将它们下载为图像文件以保存在设备存储中?

[英]Is there a way to select only the contents of the ImageView and the Textview and download them as an image file to save in the device storage?

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.我想创建一个下载按钮,以便用户可以将 ImageView 和 TextViews(位于 ImageView 顶部)的内容下载为图像文件并将其保存在设备存储中。

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).我只想选择 ImageView 和两个 TextViews 并将它们下载为图像 (PNG)。 Any help will be appreciated.任何帮助将不胜感激。

Thank You.谢谢你。

What you probably want is to save a Bitmap of what you see on the screen.您可能想要的是保存您在屏幕上看到的位图。 See this answer .看到这个答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM