3d开奖号455前后关系

Android中文API
ADC-Android API Android SDK Android Studio
当前位置: 主页 > Android开发文档 >

Android自定义View:黑客帝国数字雨

时间:2018-04-24 19:40来源:未知 作者:小q 点击:
0. 昨天又看了一遍黑客帝国,怎么说了,时隔多年,依旧那么经典,小时候看不懂,现在再看却有很多体味。小时候看时印象最深的就是数字雨了,导致我现在写代码也要是黑屏。所以

0.

zuotianyoukanleyibianheikediguo,zenmeshuole,shigeduonian,yijiuneimejingdian,xiaoshihoukanbudong,xianzaizaikanqueyouhenduotiwei。xiaoshihoukanshiyinxiangzuishendejiushishuziyule,daozhiwoxianzaixiedaimayeyaoshiheiping。suoyijintianshangwu,xianlaiwushi,nachulianggexiaoshixieleyigeshuziyukongjian,zhijieshangtu。

 

1.

3d开奖号455前后关系 xianfenxi,zaidongbi。zheiliwojiangdaimafenweiliangbufen,yigeshuziyuzhongdemeiyilienumberrainitem,haiyoujiushisuoyouliehebingqilaidenumberrain。 numberrainbijiaojiandan,jiushijichengzilinearlayoutdeyigekongjian,zaijisuanchukuanduhoutianjianumberrainitem,henjiandan,zheilijiubuzuoshuomingle,zheilizhuyaoshuoyixianumberrainitemkongjian。

2.

meiyigenumberrainitemfenweilianggebufen,congshangxiangxialiuxialaidezhuangtai,xianzaichengqiweixialiuzhuangtai,xialiuzhuangtaishizuihouyigeshuzishigaoliangde;diergezhuangtaijiushibumanquanpinghoudezhuangtai,chengqiweiwanquanzhuangtai。wanquanzhuangtaishigaoliangshuzishicongshangxiangxiashunxugaoliangde。xianghaoyihoujiukaigaoba。

3.

shangdaima

override fun onDraw(canvas: Canvas?)
{
    super.onDraw(canvas)
    configPaint()
    canvas?.let {

        if (isShowAllNumber())
        {
            drawTotalNumbers(it)
        } else
        {
            drawPartNumbers(it)
        }

    }
}

kanondrawfangfa,limiandedrawparnumbersfangfajiushiyonglaihuizhixialiuzhuangtai,zirandrawtotalnumbersjiushihuizhiwanquanzhuangtaide。jiujinghuizhineigezhuangtaishiyouisshowallnumberfangfalaipanduande

private fun isShowAllNumber(): Boolean
{
    return nowHeight >= height
}

3d开奖号455前后关系 qizhongnowheightshiyigechengyuanbianliang,daibiaozhexianzaisuoyouwenzidegaodu,zaixialiuzhuangtai,meiciduohuizhiyigewenzi,jiuhuizengjiayigewenzidegaodu。 jiexialaiwomenkandrawtotalnumbershedrawpartnumbers

private fun drawPartNumbers(canvas: Canvas)
{
    val count = (nowHeight / textSize).toInt()
    nowHeight += textSize
    drawNumbers(canvas, count)

}

private fun drawTotalNumbers(canvas: Canvas)
{
    val count = (height / textSize).toInt()
    drawNumbers(canvas, count)
}

3d开奖号455前后关系 qizhongdouyongledrawnumbers,qizhongdequbiejiushichuanrudecountzhibuyiyang,zheilidecountdaibiaowenzidegeshu。suoyizhongzhongzhizhongjiuzaiyudrawnumbersfangfale

private fun drawNumbers(canvas: Canvas, count: Int)
{
    if (count == 0)
    {
        postInvalidateDelayed(startOffset)
    } else
    {
        var offset = 0f
        for (i in 0 until count)
        {
           //生成随机文字
            val text = ((Math.random() * 9).toInt()).toString()
         
            //高亮文字颜色变高亮,否则就是一般颜色
            if (hightLightNumIndex == i)
            {
                paint.color = hightLightColor
                paint.setShadowLayer(10f, 0f, 0f, hightLightColor)

            } else
            {
                paint.color = normalColor
                paint.setShadowLayer(10f, 0f, 0f, normalColor)
            }
            //绘制文字
            canvas.drawText(text, 0f, textSize + offset, paint)
            offset += textSize
        }
          //找到下一个高亮数字的位置
        if (!isShowAllNumber())
        {
            hightLightNumIndex++
        } else
        {
            hightLightNumIndex = (++hightLightNumIndex) % count
        }
        postInvalidateDelayed(100L)
    }
}

zheiduandaimaizhuyaojiushihuizhishuzi,panduangaoliang,meishenmenandu,keyikanyixiazhushi。

4.

zheigekongjiannandubuda,danshizuochulaiganjuehaishihenyouyiside,numberrainhaiyouzidingyishuxingshenmede,jiubushuole,dajiakandaimajiukeyile zuihoufushanggithubdizhi


作者:滑板上的老砒霜
链接:http://juejin.im/post/5addd40f518825673d6cef80
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

(责任编辑:小q)
织梦二维码生成器
顶一下
(14)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
推荐内容