| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package com.android.test.dynamic; |
| 15 |
|
| 16 |
import android.app.Activity; |
| 17 |
import android.content.res.Resources; |
| 18 |
import android.graphics.drawable.BitmapDrawable; |
| 19 |
import android.os.Bundle; |
| 20 |
import android.widget.TextView; |
| 21 |
import android.widget.Button; |
| 22 |
import android.widget.GridLayout; |
| 23 |
import android.widget.ScrollView; |
| 24 |
|
| 25 |
import java.text.DecimalFormat; |
| 26 |
|
| 27 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 28 |
public class BitmapDrawableDupe extends Activity { |
| 29 |
private static final String LOGCAT = "VectorDrawable1"; |
| 30 |
protected int[] icon = { |
| 31 |
R.drawable.bitmap_drawable01, |
| 32 |
R.drawable.bitmap_drawable01, |
| 33 |
R.drawable.bitmap_drawable01, |
| 34 |
R.drawable.bitmap_drawable01, |
| 35 |
R.drawable.bitmap_drawable01, |
| 36 |
R.drawable.bitmap_drawable01, |
| 37 |
R.drawable.bitmap_drawable01, |
| 38 |
R.drawable.bitmap_drawable01, |
| 39 |
R.drawable.bitmap_drawable01, |
| 40 |
R.drawable.bitmap_drawable01, |
| 41 |
R.drawable.bitmap_drawable01, |
| 42 |
R.drawable.bitmap_drawable01, |
| 43 |
R.drawable.bitmap_drawable01, |
| 44 |
R.drawable.bitmap_drawable01, |
| 45 |
R.drawable.bitmap_drawable01, |
| 46 |
R.drawable.bitmap_drawable01, |
| 47 |
R.drawable.bitmap_drawable01, |
| 48 |
R.drawable.bitmap_drawable01, |
| 49 |
R.drawable.bitmap_drawable01, |
| 50 |
R.drawable.bitmap_drawable01, |
| 51 |
R.drawable.bitmap_drawable01, |
| 52 |
}; |
| 53 |
|
| 54 |
@Override |
| 55 |
protected void onCreate(Bundle savedInstanceState) { |
| 56 |
super.onCreate(savedInstanceState); |
| 57 |
ScrollView scrollView = new ScrollView(this); |
| 58 |
GridLayout container = new GridLayout(this); |
| 59 |
scrollView.addView(container); |
| 60 |
container.setColumnCount(5); |
| 61 |
container.setBackgroundColor(0xFF888888); |
| 62 |
|
| 63 |
DecimalFormat df = new DecimalFormat("#.##"); |
| 64 |
long time = android.os.SystemClock.elapsedRealtimeNanos(); |
| 65 |
for (int i = 0; i < icon.length; i++) { |
| 66 |
Button button = new Button(this); |
| 67 |
button.setWidth(200); |
| 68 |
button.setBackgroundResource(icon[i]); |
| 69 |
container.addView(button); |
| 70 |
} |
| 71 |
|
| 72 |
setContentView(scrollView); |
| 73 |
time = android.os.SystemClock.elapsedRealtimeNanos()-time; |
| 74 |
TextView t = new TextView(this); |
| 75 |
t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms"); |
| 76 |
container.addView(t); |
| 77 |
} |
| 78 |
} |