| 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.graphics.Canvas; |
| 22 |
import android.graphics.Paint; |
| 23 |
import android.os.Bundle; |
| 24 |
import android.util.Log; |
| 25 |
import android.view.View; |
| 26 |
|
| 27 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 28 |
public class MatrixActivity extends Activity { |
| 29 |
@Override |
| 30 |
protected void onCreate(Bundle savedInstanceState) { |
| 31 |
super.onCreate(savedInstanceState); |
| 32 |
|
| 33 |
setContentView(new MatrixView(this)); |
| 34 |
} |
| 35 |
|
| 36 |
static class MatrixView extends View { |
| 37 |
MatrixView(Context c) { |
| 38 |
super(c); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
protected void onDraw(Canvas canvas) { |
| 43 |
super.onDraw(canvas); |
| 44 |
canvas.drawRGB(255, 255, 255); |
| 45 |
|
| 46 |
Log.d("Matrix", "m1=" + canvas.getMatrix()); |
| 47 |
|
| 48 |
canvas.save(); |
| 49 |
canvas.translate(10.0f, 10.0f); |
| 50 |
Log.d("Matrix", "m2=" + canvas.getMatrix()); |
| 51 |
canvas.translate(20.0f, 20.0f); |
| 52 |
Log.d("Matrix", "m3=" + canvas.getMatrix()); |
| 53 |
canvas.restore(); |
| 54 |
} |
| 55 |
} |
| 56 |
} |