如何转换视图的转换为位图? [英] how to convert view's to bitmap?

查看:171
本文介绍了如何转换视图的转换为位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个观点的(TextView的,ImageView的)中的FrameLayout,我要保存的图像与文字。这个秘密,以位图。 XML是:

 <的FrameLayout
     机器人:ID =@ + ID /的FrameLayout
     机器人:layout_marginTop =30dip
     机器人:layout_height =FILL_PARENT
     机器人:layout_width =FILL_PARENT>

     < ImageView的
          机器人:ID =@ + ID / ImageView01
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_width =WRAP_CONTENT/>

    < TextView的机器人:ID =@ + ID / text_view
          机器人:layout_marginTop =30dip
          机器人:layout_width =WRAP_CONTENT
          机器人:MAXLINES =20
          机器人:滚动条=垂直
          机器人:layout_height =WRAP_CONTENT/>

< /的FrameLayout>
 

解决方案

如何转换成浏览位图

 的FrameLayout视图=(的FrameLayout)findViewById(R.id.framelayout);

view.setDrawingCacheEnabled(真正的);

view.buildDrawingCache();

位图BM = view.getDrawingCache();
 

I have Two view's (Textview, imageView) in the framelayout, i want to save the image with text. for this covert view to bitmap. xml is:

<FrameLayout 
     android:id="@+id/framelayout"
     android:layout_marginTop="30dip"
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent">

     <ImageView 
          android:id="@+id/ImageView01"
          android:layout_height="wrap_content" 
          android:layout_width="wrap_content"/>

    <TextView android:id="@+id/text_view"
          android:layout_marginTop="30dip"
          android:layout_width="wrap_content" 
          android:maxLines="20"
          android:scrollbars="vertical"
          android:layout_height="wrap_content"/>

</FrameLayout>

解决方案

How to convert View into Bitmap

FrameLayout view = (FrameLayout)findViewById(R.id.framelayout);

view.setDrawingCacheEnabled(true);

view.buildDrawingCache();

Bitmap bm = view.getDrawingCache();

这篇关于如何转换视图的转换为位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆