package com.mycompany.m; import android.content.*; import android.content.res.*; import android.graphics.*; import android.view.*; import android.view.animation.*; public class Draw2D extends View { Animation toy; Bitmap bit; Paint pai; public Draw2D(Context context) { super(context); pai = new Paint(); Resources ress=this.getResources(); bit = BitmapFactory.decodeResource(ress, R.drawable.ic); toy = AnimationUtils.loadAnimation(getContext(), R.anim.sun); toy.start(); } @Override protected void onDraw(Canvas canvas) { // TODO: Implement this method super.onDraw(canvas); pai.setStyle(Paint.Style.FILL); pai.setColor(Color.BLUE); canvas.drawPaint(pai); pai.setColor(Color.GREEN); canvas.drawRect(20, 200, 46, 170, pai); canvas.drawBitmap(bit, 400, 100, pai); } }