鍍金池/ 教程/ Android/ Canvas & Drawables
Launch mode 和 Intent flags專題
Canvas & Drawables
UTAustinX_UT.9.01x: Effective Thinking Through Mathematics
《JavaScript 語(yǔ)言精粹》
Memory leak專題
React基礎(chǔ)
《Test Driven Development: By Example》一書(shū)
Developer tools
安卓開(kāi)發(fā)技能樹(shù)
<a rel="nofollow" href="https://mp.weixin.qq.com/s?__biz=MzA3NDM
Best Practices for Interaction and Engagement
各個(gè)安卓版本引入的主要新特性
Building Apps with Connectivity &amp; the Cloud
List.toArray()再?gòu)?qiáng)轉(zhuǎn)是一定會(huì)失敗的
深入Android frameworks
Google dev 100 days系列視頻
Building Apps with Contacts &amp; Sign-In
關(guān)系型數(shù)據(jù)庫(kù)設(shè)計(jì)范式
《App研發(fā)錄》一書(shū)
REST API設(shè)計(jì)
Google IO 2015摘要
自定義View/ViewGroup以及高性能實(shí)現(xiàn)自定義UI
安卓系統(tǒng)點(diǎn)擊事件處理
《50 Android Hacks》一書(shū)
Building Apps with Content Sharing
Flux基礎(chǔ)
<a rel="nofollow" href="http://developer.android.com/training/in
依賴注入(以Dagger 2為例)
Java同步機(jī)制
Java對(duì)象內(nèi)存的使用情況
JSR133(Java memory model)
Google官方Material Design手冊(cè)(<a rel="nofollow" href="http://develop
Futurice公司安卓團(tuán)隊(duì)的建議
安卓性能優(yōu)化
  • 1.
Best Practices for Performance
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
<a rel="nofollow" href="http://blog.danlew.net/2014/11/19/styles
Handling Runtime Changes
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
Building Apps with Graphics &amp; Animation
<a rel="nofollow" href="http://tools.android.com/tech-docs/new-b
Android項(xiàng)目架構(gòu)
MVP(Model-View-Presenter)模式
<a rel="nofollow" href="http://www.infoq.com/cn/es6-in-depth/"">
《Android源碼設(shè)計(jì)模式解析與實(shí)戰(zhàn)》一書(shū)
Rx在Android中的最佳實(shí)踐
函數(shù)調(diào)用時(shí),傳遞參數(shù)應(yīng)該是不可變的(Immutable)
ProGuard
面向?qū)ο罅笤瓌t(SOLID+)
深入理解Java虛擬機(jī)
深入Java深淺拷貝、immutable、unmodifiable
Best Practices for User Input
UI上的一些高效方式/最佳實(shí)踐
<a rel="nofollow" href="https://blog.stylingandroid.com/ripples-
Best Practices for User Interface
安卓測(cè)試驅(qū)動(dòng)開(kāi)發(fā)/安卓測(cè)試驗(yàn)證
暗時(shí)間:學(xué)會(huì)正確思考
技術(shù)筆記
Aspect Oriented Programming(AOP)
Best Practices for Background Jobs
安卓系統(tǒng)動(dòng)效專題
Feed系統(tǒng)的設(shè)計(jì)
Data binding(MVVM,Model-View-ViewModel)
Effective Java一書(shū)筆記
<a rel="nofollow" href="http://developer.android.com/training/in
Rx (Reactive eXtention)
MultiDex專題
一些很棒的點(diǎn)子
WebRTC

Canvas &amp; Drawables

Canvas & Drawables

  • 繪制4個(gè)基本元素
    • Bitmap:保存每個(gè)像素的數(shù)據(jù)
    • Canvas:提供draw*** API,通過(guò)draw系列函數(shù)(繪制線、矩形、圓、橢圓等),把繪制結(jié)果寫(xiě)入到bitmap對(duì)象中
    • Drawing primitive:Rect, Path, text, Bitmap...
    • Paint:畫(huà)筆,描述繪制內(nèi)容的屬性(顏色、樣式)
  • 兩種用法
    • 繪制到View,只需要在View子類的onDraw方法中繪制即可,onDraw函數(shù)會(huì)傳入一個(gè)Canvas對(duì)象,使用其進(jìn)行繪制即可,由framework負(fù)責(zé)繪制流程;適用于靜態(tài)自定義圖形、簡(jiǎn)單動(dòng)態(tài)圖形;
    • 繪制到Canvas,繪制原語(yǔ)一樣,但是最后需要顯示的時(shí)候,要通過(guò)View/Surface來(lái)進(jìn)行顯示;適合復(fù)雜的動(dòng)態(tài)圖形繪制,例如視頻游戲;
  • 繪制到View
    • 適用于靜態(tài)、低幀率、簡(jiǎn)單動(dòng)態(tài)圖形的繪制,重寫(xiě)View的onDraw方法即可
    • 使用參數(shù)傳入的Canvas對(duì)象,由framework負(fù)責(zé)調(diào)用onDraw函數(shù)
    • 通過(guò)invalidate函數(shù)請(qǐng)求重繪
    • onDraw、invalidate都需要在主線程執(zhí)行,其他線程可以通過(guò)postInvalidate請(qǐng)求重繪
  • 繪制到Canvas
    • Canvas記錄(執(zhí)行)draw操作,將操作記錄到Bitmap上,最后將Bitmap顯示在Surface上
  • 繪制到SurfaceView
    • SurfaceView是View的子類,支持他線程繪制,主線程不同步等待其繪制,不需要保證60 fps
  • Drawable
    • 2D圖形的高度抽象,有一系列的子類

Drawable Resources

  • BitmapDrawable,用圖片(.png, .jpg, or .gif)創(chuàng)建drawable,xml定義為:
      <bitmap
              android:src="@mipmap/ic_launcher"
              android:gravity="top"
              />
  • NinePatchDrawable,點(diǎn)9圖(.9.png),可以在兩個(gè)方向上拉伸而不會(huì)變形
  • LayerDrawable,通過(guò)xml定義<layer-list>,里面定義多個(gè)<item>來(lái)定義多層的drawable
  • StateListDrawable,通過(guò)xml定義<selector>,里面定義多個(gè)<item>來(lái)定義具有不同狀態(tài)的drawable,實(shí)現(xiàn)按鈕點(diǎn)擊態(tài)/激活態(tài)的常用方法
  • LevelListDrawable,通過(guò)xml定義<level-list>,里面有多個(gè)<item>來(lái)實(shí)現(xiàn)類似于wifi信號(hào)強(qiáng)度這樣的drawable,例子:
      <level-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:maxLevel="0" android:drawable="@drawable/ic_wifi_signal_1" />
        <item android:maxLevel="1" android:drawable="@drawable/ic_wifi_signal_2" />
        <item android:maxLevel="2" android:drawable="@drawable/ic_wifi_signal_3" />
        <item android:maxLevel="3" android:drawable="@drawable/ic_wifi_signal_4" />
      </level-list>

    ImageView有setImageLevel(int)方法,可以設(shè)置顯示哪個(gè)強(qiáng)度

  • TransitionDrawable,通過(guò)xml定義<transition>,里面有多個(gè)<item>,類似于<layer-list>,但是支持不同layer之間的淡入淡出,通過(guò)TransitionDrawable的startTransition(int)resetTransition()來(lái)顯示某一層
  • InsetDrawable,把它設(shè)置為一個(gè)View的背景時(shí),可以與View的背景區(qū)域小于其bound,但是應(yīng)用場(chǎng)景呢?
  • ClipDrawable,把源drawable裁剪后顯示,可以通過(guò)隨時(shí)間改變裁剪區(qū)域來(lái)做出圖片逐漸展開(kāi)的效果
  • ScaleDrawable,把源drawable縮放后顯示,類似還有RotateDrawable,GradientDrawable
  • ShapeDrawable,定義基本幾何類型

AndroidFillableLoaders

  • PNG可以導(dǎo)出為SVG
  • 通過(guò)SVGParser,可以將SVG指令轉(zhuǎn)化為Path的指令,并將其繪制到Path對(duì)象中
  • DashPathEffect可以達(dá)到繪制加速邊緣的效果
  • 填滿的動(dòng)畫(huà)思路類似于WashingMachineView