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

Canvas &amp; Drawables

Canvas & Drawables

  • 繪制4個基本元素
    • Bitmap:保存每個像素的數(shù)據(jù)
    • Canvas:提供draw*** API,通過draw系列函數(shù)(繪制線、矩形、圓、橢圓等),把繪制結果寫入到bitmap對象中
    • Drawing primitive:Rect, Path, text, Bitmap...
    • Paint:畫筆,描述繪制內(nèi)容的屬性(顏色、樣式)
  • 兩種用法
    • 繪制到View,只需要在View子類的onDraw方法中繪制即可,onDraw函數(shù)會傳入一個Canvas對象,使用其進行繪制即可,由framework負責繪制流程;適用于靜態(tài)自定義圖形、簡單動態(tài)圖形;
    • 繪制到Canvas,繪制原語一樣,但是最后需要顯示的時候,要通過View/Surface來進行顯示;適合復雜的動態(tài)圖形繪制,例如視頻游戲;
  • 繪制到View
    • 適用于靜態(tài)、低幀率、簡單動態(tài)圖形的繪制,重寫View的onDraw方法即可
    • 使用參數(shù)傳入的Canvas對象,由framework負責調(diào)用onDraw函數(shù)
    • 通過invalidate函數(shù)請求重繪
    • onDraw、invalidate都需要在主線程執(zhí)行,其他線程可以通過postInvalidate請求重繪
  • 繪制到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,點9圖(.9.png),可以在兩個方向上拉伸而不會變形
  • LayerDrawable,通過xml定義<layer-list>,里面定義多個<item>來定義多層的drawable
  • StateListDrawable,通過xml定義<selector>,里面定義多個<item>來定義具有不同狀態(tài)的drawable,實現(xiàn)按鈕點擊態(tài)/激活態(tài)的常用方法
  • LevelListDrawable,通過xml定義<level-list>,里面有多個<item>來實現(xiàn)類似于wifi信號強度這樣的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)方法,可以設置顯示哪個強度

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

AndroidFillableLoaders

  • PNG可以導出為SVG
  • 通過SVGParser,可以將SVG指令轉化為Path的指令,并將其繪制到Path對象中
  • DashPathEffect可以達到繪制加速邊緣的效果
  • 填滿的動畫思路類似于WashingMachineView