1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view; 18 19 import android.app.Activity; 20 import android.graphics.Rect; 21 import android.os.Bundle; 22 import android.widget.LinearLayout; 23 import android.widget.ScrollView; 24 25 import com.android.frameworks.coretests.R; 26 27 /** 28 * This activity contains two Views, one as big as the screen, one much larger. The large one 29 * should not be able to activate its drawing cache. 30 */ 31 public class BigCache extends Activity { 32 @Override onCreate(Bundle icicle)33 protected void onCreate(Bundle icicle) { 34 super.onCreate(icicle); 35 36 final LinearLayout testBed = new LinearLayout(this); 37 testBed.setOrientation(LinearLayout.VERTICAL); 38 testBed.setLayoutParams(new ViewGroup.LayoutParams( 39 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 40 41 final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize(); 42 final Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds(); 43 final int screenWidth = windowBounds.width(); 44 final int screenHeight = windowBounds.height(); 45 46 final View tiny = new View(this); 47 tiny.setId(R.id.a); 48 tiny.setBackgroundColor(0xFFFF0000); 49 tiny.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight)); 50 51 final View large = new View(this); 52 large.setId(R.id.b); 53 large.setBackgroundColor(0xFF00FF00); 54 // Compute the height of the view assuming a cache size based on ARGB8888 55 final int height = 2 * (cacheSize / 2) / screenWidth; 56 large.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, height)); 57 58 final ScrollView scroller = new ScrollView(this); 59 scroller.setLayoutParams(new ViewGroup.LayoutParams( 60 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 61 62 testBed.addView(tiny); 63 testBed.addView(large); 64 scroller.addView(testBed); 65 66 setContentView(scroller); 67 } 68 } 69