Support Library23.2更新内容

前两天Google更新了Support Library23.2 过年来就一直在赶项目 学习的时间也少了很多 但今年我给自己也规定了一周最少也要写一篇博客 于是今天挤着时间看了看已经有些大神都已经做出Demo 一些坑基本都可以Google出来了 (这就叫比自己优秀的人比自己更努力 好吧其实还是自己太懒了)ok Let's study

更新内容

AppCompat DayNight theme

主题切换当然我们就需要两份主题对应"day" "night"

night

Paste_Image.png

Paste_Image.png

day

Paste_Image.png

相应的xml布局中需要设置背景android:background="?android:colorBackground"

Paste_Image.png

这样对应的设置就OK了
代码上也很简单

白天模式:

<pre><code>getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
recreate();</code></pre>

夜晚模式:<pre><code>getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);recreate();</code></pre>

自动模式:<pre><code>AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);</code></pre>

官方文档是这样描述自动模式的
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.
它会根据最后一次定位来选择模式,同时也可以强制改变主题模式

Bottom Sheets

官方中有讲此次更新Bootom Sheets是支持了所有View 并支持多个回调事件
STATE_COLLAPSED 折叠状态。可通过app:behavior_peekHeight来设置默认显示的高度。
STATE_SETTING 拖拽松开之后到达终点位置(collapsed or expanded)前的状态。
STATE_EXPANDED 完全展开的状态。
STATE_HIDDEN 隐藏状态。默认是false,可通过app:behavior_hideable
属性设置。

STATE_DRAGGING 被拖拽状态

Paste_Image.png
Paste_Image.png

几乎不用写什么代码就可以有效果了(!--我承认UI是有点丑)

bottomSheet.gif

同时谷歌还提供了一个类可以完成类似的操作BottomSheetDialog使用也很简单

Paste_Image.png

最后贴上整个效果


ss.gif

关于RecyclerView最主要的是他支持了WRAP_CONTENT

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容