Is it possible to save the contents of a layout'a in bitmap? For example, there is such a markup.

<FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="match_parent" android:id="@+id/ivPhotoAfter" android:layout_gravity="bottom" android:scaleType="centerCrop" android:layout_height="324dp" /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="@color/black_overlay"> <TextView android:text="" tools:text="Наименование проекта" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tvProjectName" android:layout_weight="1" android:textColor="@color/White" android:layout_margin="5dp"/> </LinearLayout> </FrameLayout> 

Can this all be saved in one bitmap and, if so, how?

    1 answer 1

    Yes you can.

    According to the request in google

    android get bitmap from layout

    And the first issue link

    This is done like this:

     FrameLayout view = (FrameLayout)findViewById(R.id.framelayout); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bm = view.getDrawingCache();