Android View Sample(1) - RecyclerView/ViewPager2/SwipeRefreshLayout/MultiWindow/ConstraintLayout

共享Github 比较好的代码示例, 代码规范 且 容易入手。

并且,自定义了一套输出log的框架,可以在运行时展现在应用界面上,更容易掌握关键。 

1. RecylerView 基础使用(可动态修改LayoutManager 为 LinearLayoutManager或者GridLayoutManager)

https://github.com/android/views-widgets-samples/tree/main/RecyclerViewhttps://github.com/android/views-widgets-samples/tree/main/RecyclerView

2. RecylerView 动态增加/删除/修改 某个item, 并且用动画过渡

views-widgets-samples/RecyclerViewAnimations at main · android/views-widgets-samples · GitHubhttps://github.com/android/views-widgets-samples/tree/main/RecyclerViewAnimations

3. SwipeRefreshLayout 下拉刷新

模拟数据3s更新 (字符串), 在创建其它示例,需要用到模拟数据,可以参考。

views-widgets-samples/SwipeRefreshLayoutBasic at main · android/views-widgets-samples · GitHubMultiple samples showing the best practices in views-widgets on Android. - views-widgets-samples/SwipeRefreshLayoutBasic at main · android/views-widgets-sampleshttps://github.com/android/views-widgets-samples/tree/main/SwipeRefreshLayoutBasic

4.SwipeRefreshLayout 下拉刷新进阶版 (实现ListView 和 自定义View 均可下拉刷新)

https://github.com/android/views-widgets-samples/tree/main/SwipeRefreshMultipleViewshttps://github.com/android/views-widgets-samples/tree/main/SwipeRefreshMultipleViews5. ViewPager2的使用 (View/Fragment/ 动态增加删除页面/ 联动TabLayout/ 模拟滑动/ 组合RecylerView/ 滑动切换效果等, 非常强大)

https://github.com/android/views-widgets-samples/tree/main/ViewPager2https://github.com/android/views-widgets-samples/tree/main/ViewPager26. MultiWindow 入门(App 内启动新的Activity, 以多窗口的形式显示出来)

PS: 应用进入多窗口模式, 最近任务栏 -> 点击应用图标 -》 多窗口打开

此外:
Activity.isInMultiWindowMode 可以判断是否在多窗口模式

intent 启动activity方式下, 加入flag 可以让应用 进入 分屏模式, 主要加new task 标志

intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK)

https://github.com/android/views-widgets-samples/tree/main/MultiWindowPlaygroundhttps://github.com/android/views-widgets-samples/tree/main/MultiWindowPlayground

7. ConstraintLayout

(约束性布局, 适合有一定基础的看,如了解了ConstraintSet.appTo(rootLayout) 

views-widgets-samples/ConstraintLayoutExamples at main · android/views-widgets-samples · GitHubhttps://github.com/android/views-widgets-samples/tree/main/ConstraintLayoutExamples

8.DataBinding (ViewDataBinding) 结合 RecyclerView使用 (不同ItemType)

封装性较强,RecyclerView.Adapter 封装成 DataBoundAdapter

https://github.com/android/views-widgets-samples/tree/main/DataBindingDataBoundRecyclerViewhttps://github.com/android/views-widgets-samples/tree/main/DataBindingDataBoundRecyclerView

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值