前兩天Google更新了Support Library23.2 過年來就一直在趕項(xiàng)目 學(xué)習(xí)的時(shí)間也少了很多 但今年我給自己也規(guī)定了一周最少也要寫一篇博客 于是今天擠著時(shí)間看了看已經(jīng)有些大神都已經(jīng)做出Demo 一些坑基本都可以Google出來了 (這就叫比自己優(yōu)秀的人比自己更努力 好吧其實(shí)還是自己太懶了)ok Let's study
更新內(nèi)容
- support-vector-drawable and animated-vector-drawable
- AppCompat DayNight theme
- Bottom Sheets
- ** RecyclerView**
- ** Custom Tabs**
- ** Leanback for Android TV**
官方地址 http://android-developers.blogspot.com/2016/02/android-support-library-232.html
部分代碼參考自(出于對(duì)他人尊重永遠(yuǎn)把他人的鏈接放在前面):https://github.com/liaohuqiu/android-support-23.2-sample
下方有本博客源碼
AppCompat DayNight theme
主題切換當(dāng)然我們就需要兩份主題對(duì)應(yīng)"day" "night"
night


day

相應(yīng)的xml布局中需要設(shè)置背景android:background="?android:colorBackground"

這樣對(duì)應(yīng)的設(shè)置就OK了
代碼上也很簡單
白天模式:
<pre><code>getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
recreate();</code></pre>
夜晚模式:<pre><code>getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);recreate();</code></pre>
自動(dòng)模式:<pre><code>AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);</code></pre>
官方文檔是這樣描述自動(dòng)模式的
When using AppCompatDelegate.MODE_NIGHT_AUTO, the time of day and your last known location (if your app has the location permissions) are used to automatically switch between day and night, while MODE_NIGHT_NO and MODE_NIGHT_YES forces the theme to never or always use a dark theme, respectively.
它會(huì)根據(jù)最后一次定位來選擇模式,同時(shí)也可以強(qiáng)制改變主題模式
Bottom Sheets
官方中有講此次更新Bootom Sheets是支持了所有View 并支持多個(gè)回調(diào)事件
STATE_COLLAPSED 折疊狀態(tài)??赏ㄟ^app:behavior_peekHeight來設(shè)置默認(rèn)顯示的高度。
STATE_SETTING 拖拽松開之后到達(dá)終點(diǎn)位置(collapsed or expanded)前的狀態(tài)。
STATE_EXPANDED 完全展開的狀態(tài)。
STATE_HIDDEN 隱藏狀態(tài)。默認(rèn)是false,可通過app:behavior_hideable
屬性設(shè)置。
STATE_DRAGGING 被拖拽狀態(tài)


幾乎不用寫什么代碼就可以有效果了(!--我承認(rèn)UI是有點(diǎn)丑)

同時(shí)谷歌還提供了一個(gè)類可以完成類似的操作BottomSheetDialog使用也很簡單

最后貼上整個(gè)效果

關(guān)于RecyclerView最主要的是他支持了WRAP_CONTENT
源碼地址:
https://github.com/EasonHolmes/AboutSupport23.2/tree/master