rt

解决方案 »

  1.   

    public Bitmap getDrawingCache () 
    Returns the bitmap in which this view drawing is cached. The returned bitmap is null when caching is disabled. If caching is enabled and the cache is not ready, this method will create it. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling this method and draw it on screen if the returned bitmap is not null.看了一下LS说的方法 , 应该可行 , 学习了。
      

  2.   

    我不知道怎样获得一个view。
    代码如下:
    View view =null;//这一部分怎样获取
    if(view.isDrawingCacheEnabled()==false){
    view.setDrawingCacheEnabled(true);
    android.graphics.Bitmap bitmap=view.getDrawingCache();
    }在线等
      

  3.   

    你所谓的获取view是获取啥view呀?布局中的?findViewById不行吗?
    楼主请说明白点 !
      

  4.   

    setContentView(R.layout.name),我想获得的是整个加载好的页面view,然后弄成一个图片。
    求教!!!
      

  5.   

    LS说的view怎样去获的呢???
      

  6.   

    LayoutInflater inflater = (LayoutInflater) mContext
    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.main, null); View view = (View) layout;
    if (view.isDrawingCacheEnabled() == false)
    view.setDrawingCacheEnabled(true);
    Bitmap bitmap = view.getDrawingCache();
    return bitmap;运行代码时出现空指针异常,求解????
      

  7.   

    1. 为layout设置一个ID a
    2. 直接使用findViewByID(R.id.a)就OK了
      

  8.   

    View layout = inflater.inflate(R.layout.main, null);
    运行到这儿不能找到资源。source not find .不知道为什么,求解,急急急!!!
      

  9.   

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/test"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
        
        <Button android:id="@+id/start"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="start"/>
        
             <Button android:id="@+id/stop"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="stop"/>
    </LinearLayout>比如在这段xml里面,只需要View view = findViewById(R.id.test);
    view.setDrawingCacheEnabled(true);
    Bitmap bitmap = view.getDrawingCache();
      

  10.   

    虽然这个贴沉了很久很久,不过巧好碰到相同问题,作个Mark:View view = findViewById(R.id.test);
    Bitmap bit = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bit);
    view.draw(c);
      

  11.   

    请问10楼解决这个问题没?我也碰到了,好头大!一直空指针,我认为可能是要将View显示出来才能得到DrawCache的,inflat出来的貌似不行。有谁知道的吗?请教,谢谢