欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

一個(gè)很酷的加載loading效果

一個(gè)很酷的加載loading效果,自定義LeafLoadingView實(shí)現(xiàn),LeafLoadingView繼承view,
本例子主要由以下幾點(diǎn)構(gòu)成
(1):RotateAnimation實(shí)現(xiàn)葉子旋轉(zhuǎn)
(2):葉子飄動(dòng)
(3):當(dāng)前進(jìn)度繪制當(dāng)前進(jìn)度條
大體實(shí)現(xiàn):
 @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)和四川雅安電信機(jī)房的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗(yàn)和案例。

        // 繪制進(jìn)度條和葉子
        // 之所以把葉子放在進(jìn)度條里繪制,主要是層級(jí)原因
        drawProgressAndLeafs(canvas);
        // drawLeafs(canvas);

        canvas.drawBitmap(mOuterBitmap, mOuterSrcRect, mOuterDestRect, mBitmapPaint);

        postInvalidate();
    }

    private void drawProgressAndLeafs(Canvas canvas) {

        if (mProgress >= TOTAL_PROGRESS) {
            mProgress = 0;
        }
        // mProgressWidth為進(jìn)度條的寬度,根據(jù)當(dāng)前進(jìn)度算出進(jìn)度條的位置
        mCurrentProgressPosition = mProgressWidth * mProgress / TOTAL_PROGRESS;
        // 即當(dāng)前位置在圖中所示1范圍內(nèi)
        if (mCurrentProgressPosition < mArcRadius) {
            Log.i(TAG, "mProgress = " + mProgress + "---mCurrentProgressPosition = "
                    + mCurrentProgressPosition
                    + "--mArcProgressWidth" + mArcRadius);
            // 1.繪制白色ARC,繪制orange ARC
            // 2.繪制白色矩形

            // 1.繪制白色ARC
            canvas.drawArc(mArcRectF, 90, 180, false, mWhitePaint);

            // 2.繪制白色矩形
            mWhiteRectF.left = mArcRightLocation;
            canvas.drawRect(mWhiteRectF, mWhitePaint);

            // 繪制葉子
            drawLeafs(canvas);

            // 3.繪制棕色 ARC
            // 單邊角度
            int angle = (int) Math.toDegrees(Math.acos((mArcRadius - mCurrentProgressPosition)
                    / (float) mArcRadius));
            // 起始的位置
            int startAngle = 180 - angle;
            // 掃過(guò)的角度
            int sweepAngle = 2 * angle;
            Log.i(TAG, "startAngle = " + startAngle);
            canvas.drawArc(mArcRectF, startAngle, sweepAngle, false, mOrangePaint);
        } else {
            Log.i(TAG, "mProgress = " + mProgress + "---transfer-----mCurrentProgressPosition = "
                    + mCurrentProgressPosition
                    + "--mArcProgressWidth" + mArcRadius);
            // 1.繪制white RECT
            // 2.繪制Orange ARC
            // 3.繪制orange RECT
            // 這個(gè)層級(jí)進(jìn)行繪制能讓葉子感覺(jué)是融入棕色進(jìn)度條中

            // 1.繪制white RECT
            mWhiteRectF.left = mCurrentProgressPosition;
            canvas.drawRect(mWhiteRectF, mWhitePaint);
            // 繪制葉子
            drawLeafs(canvas);
            // 2.繪制Orange ARC
            canvas.drawArc(mArcRectF, 90, 180, false, mOrangePaint);
            // 3.繪制orange RECT
            mOrangeRectF.left = mArcRightLocation;
            mOrangeRectF.right = mCurrentProgressPosition;
            canvas.drawRect(mOrangeRectF, mOrangePaint);

        }

    }

    /**
     * 繪制葉子
     *
     * @param canvas
     */
    private void drawLeafs(Canvas canvas) {
        mLeafRotateTime = mLeafRotateTime <= 0 ? LEAF_ROTATE_TIME : mLeafRotateTime;
        long currentTime = System.currentTimeMillis();
        for (int i = 0; i < mLeafInfos.size(); i++) {
            Leaf leaf = mLeafInfos.get(i);
            if (currentTime > leaf.startTime && leaf.startTime != 0) {
                // 繪制葉子--根據(jù)葉子的類(lèi)型和當(dāng)前時(shí)間得出葉子的(x,y)
                getLeafLocation(leaf, currentTime);
                // 根據(jù)時(shí)間計(jì)算旋轉(zhuǎn)角度
                canvas.save();
                // 通過(guò)Matrix控制葉子旋轉(zhuǎn)
                Matrix matrix = new Matrix();
                float transX = mLeftMargin + leaf.x;
                float transY = mLeftMargin + leaf.y;
                Log.i(TAG, "left.x = " + leaf.x + "--leaf.y=" + leaf.y);
                matrix.postTranslate(transX, transY);
                // 通過(guò)時(shí)間關(guān)聯(lián)旋轉(zhuǎn)角度,則可以直接通過(guò)修改LEAF_ROTATE_TIME調(diào)節(jié)葉子旋轉(zhuǎn)快慢
                float rotateFraction = ((currentTime - leaf.startTime) % mLeafRotateTime)
                        / (float) mLeafRotateTime;
                int angle = (int) (rotateFraction * 360);
                // 根據(jù)葉子旋轉(zhuǎn)方向確定葉子旋轉(zhuǎn)角度
                int rotate = leaf.rotateDirection == 0 ? angle + leaf.rotateAngle : -angle
                        + leaf.rotateAngle;
                matrix.postRotate(rotate, transX
                        + mLeafWidth / 2, transY + mLeafHeight / 2);
                canvas.drawBitmap(mLeafBitmap, matrix, mBitmapPaint);
                canvas.restore();
            } else {
                continue;
            }
        }
    }

 

運(yùn)行效果:

  • 一個(gè)很酷的加載loading效果

一個(gè)很酷的加載loading效果


本文題目:一個(gè)很酷的加載loading效果
當(dāng)前網(wǎng)址:http://chinadenli.net/article40/jiipho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、網(wǎng)站收錄、靜態(tài)網(wǎng)站、面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司