最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android自定義View之繼承TextView繪制背景

 更新時(shí)間:2016年05月25日 10:18:39   作者:Brioal  
這篇文章主要為大家詳細(xì)介紹了Android自定義View之繼承TextView繪制背景的相關(guān)資料,需要的朋友可以參考下

本文實(shí)例為大家分享了TextView繪制背景的方法,供大家參考,具體內(nèi)容如下

效果:

這里寫圖片描述

實(shí)現(xiàn)流程:

這里寫圖片描述

1.初始化:對(duì)畫筆進(jìn)行設(shè)置

mPaintIn = new Paint();
mPaintIn.setAntiAlias(true);
mPaintIn.setDither(true);
mPaintIn.setStyle(Paint.Style.FILL);    

mPaintIn.setColor(getResources().getColor(R.color.colorPrimary));

mPaintOut = new Paint();
mPaintOut.setAntiAlias(true);
mPaintOut.setDither(true);
mPaintOut.setStyle(Paint.Style.FILL);   

mPaintOut.setColor(getResources().getColor(R.color.colorAccent));

2.繪制外框,內(nèi)框,文字

獲取組件寬高

int width = getMeasureWidth();
int height = getMeasureHeight();

繪制

@Override
  protected void onDraw(Canvas canvas) {
    //繪制背景,在繪制文字之前繪制
    canvas.drawRect(new Rect(0, 0, getMeasuredWidth(), getMeasuredHeight()), mPaintIn);
    canvas.drawRect(new Rect(10, 10, getMeasuredWidth()-10, getMeasuredHeight()-10), mPaintOut);

    super.onDraw(canvas);
  }


以上就是本文的全部?jī)?nèi)容,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

五寨县| 库伦旗| 亳州市| 库车县| 景洪市| 额尔古纳市| 定南县| 文山县| 沽源县| 德化县| 泸州市| 永善县| 安平县| 新建县| 白玉县| 南溪县| 开平市| 拜城县| 潮州市| 沈阳市| 汉阴县| 彝良县| 天门市| 宝坻区| 孟村| 将乐县| 济源市| 涟水县| 黑山县| 陇南市| 安西县| 耒阳市| 宣城市| 山东| 融水| 县级市| 科尔| 金堂县| 延寿县| 遵义市| 新泰市|