| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.test.hwui; |
| 18 |
|
| 19 |
import android.app.Activity; |
| 20 |
import android.content.Context; |
| 21 |
import android.content.res.Resources; |
| 22 |
import android.graphics.Canvas; |
| 23 |
import android.graphics.drawable.Drawable; |
| 24 |
import android.os.Bundle; |
| 25 |
import android.view.Gravity; |
| 26 |
import android.view.View; |
| 27 |
import android.widget.FrameLayout; |
| 28 |
|
| 29 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 30 |
public class MoreNinePatchesActivity extends Activity { |
| 31 |
@Override |
| 32 |
protected void onCreate(Bundle savedInstanceState) { |
| 33 |
super.onCreate(savedInstanceState); |
| 34 |
|
| 35 |
FrameLayout layout = new FrameLayout(this); |
| 36 |
PatchView b = new PatchView (this); |
| 37 |
b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, |
| 38 |
FrameLayout.LayoutParams.MATCH_PARENT, Gravity.CENTER)); |
| 39 |
layout.addView(b); |
| 40 |
layout.setBackgroundColor(0xffffffff); |
| 41 |
|
| 42 |
setContentView(layout); |
| 43 |
} |
| 44 |
|
| 45 |
private class PatchView extends View { |
| 46 |
private final Drawable mDrawable1; |
| 47 |
private final Drawable mDrawable2; |
| 48 |
private final Drawable mDrawable3; |
| 49 |
|
| 50 |
private PatchView(Context context) { |
| 51 |
super(context); |
| 52 |
Resources res = context.getResources(); |
| 53 |
mDrawable1 = res.getDrawable(R.drawable.progress_vertical_holo_dark); |
| 54 |
mDrawable2 = res.getDrawable(R.drawable.scrubber_progress_vertical_holo_dark); |
| 55 |
mDrawable3 = res.getDrawable(R.drawable.scrubber_vertical_primary_holo); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
protected void onDraw(Canvas canvas) { |
| 60 |
super.onDraw(canvas); |
| 61 |
|
| 62 |
canvas.translate(100, 100); |
| 63 |
mDrawable1.setBounds(0, 0, 33, 120); |
| 64 |
mDrawable1.setLevel(5000); |
| 65 |
mDrawable1.draw(canvas); |
| 66 |
|
| 67 |
canvas.translate(20, 0); |
| 68 |
mDrawable2.setBounds(0, 0, 33, 120); |
| 69 |
mDrawable2.setLevel(5000); |
| 70 |
mDrawable2.draw(canvas); |
| 71 |
|
| 72 |
canvas.translate(20, 0); |
| 73 |
mDrawable3.setBounds(0, 0, 33, 120); |
| 74 |
mDrawable3.draw(canvas); |
| 75 |
} |
| 76 |
} |
| 77 |
} |