最新国产好看的视频,伊人天堂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)論

沙湾县| 上饶市| 左权县| 定陶县| 丽水市| 原平市| 惠水县| 醴陵市| 苏州市| 嘉峪关市| 二连浩特市| 广宁县| 大姚县| 蒙阴县| 资兴市| 合山市| 佛山市| 沁阳市| 三明市| 秦安县| 保山市| 双鸭山市| 拉孜县| 新巴尔虎右旗| 马边| 昭苏县| 农安县| 綦江县| 陵水| 襄樊市| 黄浦区| 岑巩县| 临西县| 光泽县| 贞丰县| 阿克苏市| 亳州市| 上蔡县| 正镶白旗| 寿宁县| 郓城县|