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说的方法 , 应该可行 , 学习了。
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说的方法 , 应该可行 , 学习了。
代码如下:
View view =null;//这一部分怎样获取
if(view.isDrawingCacheEnabled()==false){
view.setDrawingCacheEnabled(true);
android.graphics.Bitmap bitmap=view.getDrawingCache();
}在线等
楼主请说明白点 !
求教!!!
.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;运行代码时出现空指针异常,求解????
2. 直接使用findViewByID(R.id.a)就OK了
运行到这儿不能找到资源。source not find .不知道为什么,求解,急急急!!!
<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();
Bitmap bit = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bit);
view.draw(c);