編輯:關於Android編程
package cn.llbb.testsurfaceviewdemo; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Rect; import android.graphics.RectF; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback; import android.view.SurfaceView; public class MySurfaceView extends SurfaceView implements Callback { private SurfaceHolder sfh; private Canvas canvas; private Paint paint; public MySurfaceView(Context context) { super(context); sfh = getHolder(); sfh.addCallback(this); paint = new Paint(); paint.setColor(Color.RED); setFocusable(true); } public void surfaceCreated(SurfaceHolder holder) { MyDraw(); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceDestroyed(SurfaceHolder holder) { } private void MyDraw(){ try{ canvas = sfh.lockCanvas(); if(canvas != null){ canvas.drawColor(Color.WHITE); canvas.drawText("drawtext", 10, 10, paint); canvas.drawPoint(10, 20, paint); canvas.drawPoints(new float[]{10,30,30,30}, paint); canvas.drawLine(10,40,50,40, paint); canvas.drawLines(new float[]{10,50,50,50,70,50,110,50}, paint); canvas.drawRect(10,60,40,100, paint); Rect rect = new Rect(10,110,60,130); canvas.drawRect(rect, paint); RectF rectf = new RectF(10,140,60,170); canvas.drawRoundRect(rectf, 20, 20, paint); canvas.drawCircle(20, 200, 20, paint); canvas.drawArc(new RectF(150,20,200,70), 0, 230, true, paint); canvas.drawOval(new RectF(150,80,180,100), paint); Path path = new Path(); path.moveTo(160,150); path.lineTo(200,150); path.lineTo(180,200); path.close(); canvas.drawPath(path, paint); Path pathcircle = new Path(); pathcircle.addCircle(130, 260, 20, Path.Direction.CCW); canvas.drawTextOnPath("pathtext", pathcircle, 10, 20, paint); } }catch(Exception e){ }finally{ sfh.unlockCanvasAndPost(canvas); } } } MainActivity.java package cn.llbb.testcanvasdemo; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(new MySurfaceView(this)); } }
Android中所有控件(也稱組件)都繼承自adnroid.view.View類,android.view.ViewGroup是View類的重要子類,絕大多書的布局類就繼
美團電商應用平台大家使用非常頻繁,下面小編通過本文給大家介紹電商應用平台中常用的選擇類別下拉列表的實現。先給大家展示下效果圖:一、下拉列表的實現其實實現方法有很多,這時實
android系統介紹Android(安卓),是一個以Linux為基礎的開源移動設備操作系統,主要用於智能手機和平板電腦,由Google成立的Open Handset A
Android開源框架Universal-Image-Loader就像圖片加載守護者,為我們提供了豐富的功能特性:(1)多線程加載圖像(異步或同步);(2)高度可定制化i