Java Code Examples for android.view.ViewGroup#setPersistentDrawingCache()

The following examples show how to use android.view.ViewGroup#setPersistentDrawingCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transition3d.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.animations_main_screen);

    mPhotosList = (ListView) findViewById(android.R.id.list);
    mImageView = (ImageView) findViewById(R.id.picture);
    mContainer = (ViewGroup) findViewById(R.id.container);

    // Prepare the ListView
    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, PHOTOS_NAMES);

    mPhotosList.setAdapter(adapter);
    mPhotosList.setOnItemClickListener(this);

    // Prepare the ImageView
    mImageView.setClickable(true);
    mImageView.setFocusable(true);
    mImageView.setOnClickListener(this);

    // Since we are caching large views, we want to keep their cache
    // between each animation
    mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
}
 
Example 2
Source File: Transition3d.java    From AnimationApiDemos with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// 布局中就是一个ListView和一个ImageView重叠放在一个FrameLayout中
	setContentView(R.layout.animations_main_screen);

	mPhotosList = (ListView) findViewById(android.R.id.list);
	mImageView = (ImageView) findViewById(R.id.picture);
	mContainer = (ViewGroup) findViewById(R.id.container);

	// Prepare the ListView
	final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
			android.R.layout.simple_list_item_1, PHOTOS_NAMES);

	mPhotosList.setAdapter(adapter);
	mPhotosList.setOnItemClickListener(this);

	// Prepare the ImageView
	mImageView.setClickable(true);
	mImageView.setFocusable(true);
	mImageView.setOnClickListener(this);

	// Since we are caching large views, we want to keep their cache
	// between each animation
	mContainer
			.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
	// 为了使动画效果比较流畅这里还通过persistentDrawingCache设置了控件的绘制缓存策略,一共有4种策略:
	// PERSISTENT_NO_CACHE 说明不在内存中保存绘图缓存;
	// PERSISTENT_ANIMATION_CACHE 说明只保存动画绘图缓存;
	// PERSISTENT_SCROLLING_CACHE 说明只保存滚动效果绘图缓存
	// PERSISTENT_ALL_CACHES 说明所有的绘图缓存都应该保存在内存中。

}