編輯:關於Android編程
public class Demo01 extends Activity{ private Bitmap bitmap = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MyView(this, R.drawable.background)); } private class MyView extends View{ private final int WIDTH = 20; private final int HEIGHT = 20; private final int COUNT = (WIDTH+1)*(HEIGHT+1); private final float[] verts = new float[COUNT*2]; private final float[] orgs = new float[COUNT*2]; public MyView(Context context,int drawableId) { super(context); setFocusable(true); bitmap = BitmapFactory.decodeResource(getResources(), drawableId); float bitmapWidth = bitmap.getWidth(); float bitmapHeight = bitmap.getHeight(); int index = 0; for(int y=0;y<=HEIGHT;y++){ float fy = bitmapHeight / WIDTH * y; for(int x = 0;x<=WIDTH;x++){ float fx = bitmapWidth / HEIGHT * x; verts[index*2 + 0 ] = orgs[index*2 + 0] = fx; verts[index*2 + 1 ] = orgs[index*2 + 1] = fy; index ++; } } setBackgroundColor(Color.WHITE); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmapMesh(bitmap, WIDTH, HEIGHT, verts, 0, null, 0, null); } private void warp(float fx , float fy){ for(int i=0;i1){ verts[i+0] = fx; verts[i+1] = fy; }else{ verts[i+0] = orgs[i+0] + dx*pull; verts[i+1] = orgs[i+1] + dy*pull; } } invalidate(); } @Override public boolean onTouchEvent(MotionEvent event) { warp(event.getX(),event.getY()); return true; } } }
BroadcastReceiver除了接收用戶所發送的廣播消息之外,還有一個重要的用途:接收系統廣播。如果應用需要在系統特定時刻執行某些操作,就
使用實現了單選功能的ListView,不要問為什麼不使用RecyclerView,RecyclerView真的做得不如ListView和GridView完善全面,但是Re
本文實例講述了Android控件之ProgressBar用法。分享給大家供大家參考。具體如下:ProgressBar位於android.widget包下,其繼承於View
喜歡K歌的小伙伴注意啦啦!萬眾期待的酷狗ktv手機版終於上線啦!現在,只要下載了酷狗ktv的手機版,不用去K房,在家也一樣可以開啟唱K模式!那麼,作為酷狗旗