Support Library23.2更新內(nèi)容

前兩天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)容

AppCompat DayNight theme

主題切換當(dāng)然我們就需要兩份主題對(duì)應(yīng)"day" "night"

night

Paste_Image.png

Paste_Image.png

day

Paste_Image.png

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

Paste_Image.png

這樣對(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)

Paste_Image.png
Paste_Image.png

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

bottomSheet.gif

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

Paste_Image.png

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


ss.gif

關(guān)于RecyclerView最主要的是他支持了WRAP_CONTENT

源碼地址:
https://github.com/EasonHolmes/AboutSupport23.2/tree/master

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容