Android中怎么通過(guò)自定義view實(shí)現(xiàn)進(jìn)度條加載效果,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
我們提供的服務(wù)有:成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、順城ssl等。為1000多家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的順城網(wǎng)站制作公司
分析圖:
代碼如下:
package com.example.dotloadview; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Handler; import android.util.AttributeSet; import android.view.View; /** * Created by zhouguizhi on 6/18/15. */ public class DotLoadProgressView extends View { private boolean isStart = false; private int dotIndex =0;//點(diǎn)下面的角標(biāo) private int dotNumber = 0; private Paint mPaint; private int paddingTop = 50; private int paddingBottom = 50; private int paddingLeft = 30; private int paddingRight = 30; private Handler mHandler = new Handler(); private long DELAY_TIME = 300; private Bitmap bitmap; private int itemDotSpace = 10;//二個(gè)點(diǎn)之間的距離 private Bitmap moveBitmap ; private Runnable mRunnable = new Runnable() { @Override public void run() { if (dotNumber != 0){ dotIndex = (dotIndex + 1) % dotNumber; } invalidate(); mHandler.postDelayed(mRunnable, DELAY_TIME); } }; public DotLoadProgressView(Context context, AttributeSet attrs) { super(context, attrs); moveBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.active_dot); init(); } private void init() { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.FILL); mPaint.setDither(true); mPaint.setAntiAlias(true); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); for(int i=0;i布局代碼:
關(guān)于Android中怎么通過(guò)自定義view實(shí)現(xiàn)進(jìn)度條加載效果問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
當(dāng)前文章:Android中怎么通過(guò)自定義view實(shí)現(xiàn)進(jìn)度條加載效果
分享路徑:http://weahome.cn/article/jeecjo.html