這篇文章給大家介紹如何在Android中利用View顯示分?jǐn)?shù),內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
所用的知識:
(1)自定義View中的 path ,主要用來繪制指示塊。
(2)屬性動畫-ValueAnimator,并設(shè)置屬性動畫的監(jiān)聽器。
(3)根據(jù)屬性動畫是否結(jié)束的標(biāo)志,決定是否繪制分?jǐn)?shù)對應(yīng)的描述文本內(nèi)容。
實現(xiàn)步驟:
繼承自View,在構(gòu)造函數(shù)中獲取自定義屬性和初始化操作(初始化畫筆)
private void obtainAttrs(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ScoreView); lineLength = typedArray.getDimension(R.styleable.ScoreView_lineLength, dp2Px(10)); lineColor = typedArray.getColor(R.styleable.ScoreView_lineColor, Color.WHITE); typedArray.recycle(); } private void init() { arrowPaint = createPaint(Color.WHITE, 0, Paint.Style.FILL, 0); arcPaint = createPaint(lineColor, dp2Px(1), Paint.Style.STROKE, 0); bgPaint = createPaint(lineColor, dp2Px(1), Paint.Style.FILL, 0); reachProgressPaint = createPaint(Color.WHITE, dp2Px(1), Paint.Style.FILL, 0); arcReachPaint = createPaint(Color.WHITE, dp2Px(1), Paint.Style.STROKE, 0); scoreTextPaint = createPaint(Color.WHITE, 0, Paint.Style.STROKE, dp2Px(26)); descTextPaint = createPaint(Color.WHITE, 0, Paint.Style.STROKE, dp2Px(16)); }
新聞名稱:如何在Android中利用View顯示分?jǐn)?shù)-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://chinadenli.net/article14/peige.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、用戶體驗、移動網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、外貿(mào)建站、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)