本文共 10123 字,大约阅读时间需要 33 分钟。
> Android 5.0 新特性
1.谷歌将为自家的语音服务Google Now 加入一个名为 OK Google Everywhere 的全新功能; 2.Android 5.0 将会加入更多的健身功能,考虑到谷歌在发布了Android Wear,后者与智能手表及谷歌眼镜等可穿戴设备的协作应该会成为下个版本的重点功能;多种设备的支持 3.整合碎片化; 4.支持64位处理器。 5.使用ART虚拟机。 6.原生设计,Material Design设计风格 7.Project Volta电池续航改进计划等;8.SDK5.0 自定义RemoteView来实现折叠式Notification通知
9.SDK5.0 悬挂式通知Notification 10.新增CardView、RecyclerView、design、appcompat、palette等。不同于ListView,RecyclerView需要通过LayoutManager来管理和回收Item View,你可以通过继承RecyclerView.LayoutManager实现自己的LayoutManager,也可以使用现有的LayoutManager:LinearLayoutManager, GridLayoutManager ,StaggeredGridLayoutManager; 11.新增内容就包括有Android Studio、Gradle、Material Design、运行时权限、多窗口模式、RecyclerView、百分比布局、Lambda表达式、OkHttp、Doze模式等 12.Material Design方方面面的知识,包括讲解了Toolbar、 滑动菜单、 NavigationView、 悬浮按钮、 Snackbar、 CoordinatorLayout、 卡片式布局、 下拉刷新、 折叠式标题栏等. -- 根据包名判断 App 运行状态,监听电源键和home键。获取栈顶Activity? Android获取栈顶程序- http://blog.csdn.net/ballonge/article/details/51085953 5.0版本之后google废弃了getRunningTasks()方法,意味着我们在5.0以后不能通过该方法获取正在运行的应用程序,google在5.0又提供类新的api,那就是getRunningAppProcesses(),通过ActivityManager的getRunningAppProcesses()方法也可以获取正在运行的应用程序。 但是,在5.1的版本发布后getRunningAppProcesses()已经获取不到正在运行的服务...Android在5.0版本google提供了一个UsageStatsManager类,通过这个类可以获取到应用程序的运行情况. 读取Android proc文件系统,适用于Android 6.0及以下- https://github.com/jaredrummler/AndroidProcesses> Recyclerview,CardView,DrawerLayout,Toolbar,appcompat、palette,Snackbar,CoordinatorLayout,NavigationView
-- Recyclerview动态添加和删除头部尾部,添加分割线及交互动画效果
Recyclerview动态添加和删除头部尾部- 关于Recyclerview 实现多选,单选,全选,反选,批量删除的功能的实现- https://github.com/guohaosir/RecyclerDemorecyclerview你不知道的一些事https://github.com/simplezhli/RecyclerViewExtensionsDemo
RecyclerView 技术栈: http://android.jobbole.com/83617/?utm_source=group.jobbole.com&utm_medium=relatedArticles
分享一种 RecyclerView 滑动到底部自动加载的实现方案- http://mp.weixin.qq.com/s/Oivap3YCeT5IXsVpl7n-lQ scrollview嵌套recyclerView(多布局)显示不全,滑动冲突- http://blog.csdn.net/iamdingruihaha/article/details/54772834?ref=myread RecyeclerView.jar下载- http://download.csdn.net/detail/sunalongl/9564744 , http://download.csdn.net/download/qq_24452923/8360201 ,http://download.csdn.net/download/wgx1210468313/9599438 RecyclerView的高级用法(定制动画)- http://blog.csdn.net/qibin0506/article/details/47250299 RecyclerView自定义LayoutManager,打造不规则布局- http://blog.csdn.net/qibin0506/article/details/52676670 ListView+CheckBox两种解决方案及原因分析- http://blog.csdn.net/qibin0506/article/details/44306633 那些酷炫的RecyclerView开源库整理: http://android.jobbole.com/83410/?utm_source=group.jobbole.com&utm_medium=relatedArticles RecyclerView开源库: https://github.com/CameloeAnthony/Learning-RecyclerViewAndroid RecyclerView 使用完全解析 体验艺术般的控件 http://blog.csdn.net/lmj623565791/article/details/45059587
https://github.com/gabrielemariotti/RecyclerViewItemAnimators-- Android L全新的View控件:RecyclerView,CardView,v4.widget.DrawerLayout,v7.widget.Toolbar
CardView、RecyclerView、design、appcompat、palette支持包- http://download.csdn.net/detail/u013116210/9374187 Android5.x Toolbar和Palette应用解析;Android5.x CardView 应用解析;Android5.x RecyclerView 应用解析 Android L中的RecyclerView 、CardView 、Palette的使用-- http://blog.csdn.net/xyz_lmn/article/details/38735117 Android通过Palette来动态决定UI色彩风格-- http://blog.csdn.net/zhangweiwtmdbf/article/details/45038619 ANDROID L(5.0)- http://blog.csdn.net/a396901990/article/category/2634371 Android5.X 新特性详解,Material Design UI的新体验- http://blog.csdn.net/qq_26787115/article/details/51286511 Android RecyclerView 使用完全解析 体验艺术般的控件-http://blog.csdn.net/lmj623565791/article/details/45059587 ANDROID L——RecyclerView,CardView导入和使用(Demo)-http://blog.csdn.net/vrix/article/details/44178011 Android5.x Toolbar和Palette应用解析- http://blog.csdn.net/itachi85/article/details/50150747 Android5.x CardView 应用解析- http://blog.csdn.net/itachi85/article/details/50067127 Android5.x Notification应用解析-- http://blog.csdn.net/itachi85/article/details/50096609 Android L中的RecyclerView 、CardView 、Palette的使用: http://blog.csdn.net/gaowenhui2008/article/details/43953081 Android应用开发:CardView的使用及兼容: http://blog.csdn.net/airk000/article/details/39520977 android 5.0+6.0新特性 http://blog.csdn.net/u012360634/article/details/50405265 Android5.x新特性之 Toolbar和Theme的使用 http://blog.csdn.net/feiduclear_up/article/details/46457433 google原生Material design非官方中文指导手册-- http://download.csdn.net/download/bbld_/8074157 Android开发:Translucent System Bar 的最佳实践-- http://www.jianshu.com/p/0acc12c29c1b# , https://github.com/D-clock/AndroidSystemUiTraining 最详细的 Android Toolbar 开发实践总结 http://www.codeceo.com/article/android-toolbar-develop.html Toolbar是在 Android 5.0 开始推出的一个 Material Design 风格的导航控件,引入 appcompat-v7 的兼容包,使用 android.support.v7.widget.Toolbar 进行开发。 Android Material Design之Toolbar与Palette实践 http://blog.csdn.net/jdsjlzx/article/details/41441083/ Material Design之Toolbar与Palette实践 -- http://download.csdn.net/download/bbld_/8191251-- CardView继承于Framelayout,所以Framelayout的属性他都有,同时CardView还有几个特殊的属性:
在API21(Android L)等级以上拥有属性elevation,意为CardView的Z轴阴影,只有L平台有效。只能通过xml中的elevation属性指定; 其余(2.0以上)有属性cardBackgroundColor,意为CardView的卡片颜色,只能通过xml的cardBackgroundColor进行指定; 其余(2.0以上)有属性cardConerRadius,意为CardView卡片的四角圆角矩形程度,单位dimen(dp px sp),可以通过xml指定,也可以通过代码中的setRadius指定。注意:cardView必须使用库工程,而不能使用jar包,原因是其引用了自定义属性,
但是,如果必须要使用cardView而不导入工程,建议使用cardview源码http://download.csdn.net/detail/qq379454816/9305895#comment,主要步骤如下: ①将自定义attr,color,dimens,styles拷贝至工程目录下 ②修改源码中的 import android.support.v7.cardview.R; 成当前工程的R资源CardView_cardBackgroundColor 设置背景色
CardView_cardCornerRadius 设置圆角大小 CardView_cardElevation 设置z轴阴影 CardView_cardMaxElevation 设置z轴最大高度值 CardView_cardUseCompatPadding 是否使用CompadPadding CardView_cardPreventCornerOverlap 是否使用PreventCornerOverlap CardView_contentPadding 内容的padding CardView_contentPaddingLeft 内容的左padding CardView_contentPaddingTop 内容的上padding CardView_contentPaddingRight 内容的右padding CardView_contentPaddingBottom 内容的底padding> bug: RecyclerView adapter出现空白的Item
刚开始的实现思路是控制Item的Viesible或者gone但是显示的结果却是在每个分类的header下面依旧会显示一段空白的区域..所以就通过控制Item的params属性,来实现该效果. RecycleView隐藏部分Item- http://blog.csdn.net/u011060103/article/details/52780844 class VideoViewHolder extends RecyclerView.ViewHolder { JCVideoPlayerStandard jcVideoPlayer; TextView showTv;// @Bind(R.id.image_view)
// ImageView imageView; public void setVisibility(boolean isVisible) { RecyclerView.LayoutParams param = (RecyclerView.LayoutParams) itemView.getLayoutParams(); if (isVisible) { param.height = RelativeLayout.LayoutParams.WRAP_CONTENT;// 这里注意使用自己布局的根布局类型 param.width = RelativeLayout.LayoutParams.MATCH_PARENT;// 这里注意使用自己布局的根布局类型 itemView.setVisibility(View.VISIBLE); } else { itemView.setVisibility(View.GONE); param.height = 0; param.width = 0; } itemView.setLayoutParams(param); }public VideoViewHolder(View view) {
super(view); // ButterKnife.bind(this, itemView); jcVideoPlayer = (JCVideoPlayerStandard) view.findViewById(R.id.videoplayer); showTv = (TextView) view.findViewById(R.id.show_position_tv); } }使用:((VideoViewHolder) holder).setVisibility(true);
>RecycleView列表的Item是否可见
RecycleView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); //判断是当前layoutManager是否为LinearLayoutManager // 只有LinearLayoutManager才有查找第一个和最后一个可见view位置的方法 if (layoutManager instanceof LinearLayoutManager) { LinearLayoutManager linearManager = (LinearLayoutManager) layoutManager; //获取最后一个可见view的位置 int lastItemPosition = linearManager.findLastVisibleItemPosition(); //获取第一个可见view的位置 int firstItemPosition = linearManager.findFirstVisibleItemPosition(); if (foodsArrayList.get(firstItemPosition) instanceof Foods) { int foodTypePosion = ((Foods) foodsArrayList.get(firstItemPosition)).getFood_stc_posion(); FoodsTypeListview.getChildAt(foodTypePosion).setBackgroundResource(R.drawable.choose_item_selected); } System.out.println(lastItemPosition + " " + firstItemPosition); } }});
> RecyclerView Item置顶的优雅解决方案(点击置顶、刷新置顶等)
RecyclerView本身两个常用的滑动方法: smoothScrollToPosition( int position )方法;smoothScrollBy( int dx, int dy )方法 public class TopLayoutManager extends LinearLayoutManager { public TopLayoutManager(Context context) { super(context); } public TopLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } public TopLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { RecyclerView.SmoothScroller smoothScroller = new TopSmoothScroller(recyclerView.getContext()); smoothScroller.setTargetPosition(position); startSmoothScroll(smoothScroller); } private static class TopSmoothScroller extends LinearSmoothScroller { TopSmoothScroller(Context context) { super(context); } /** * 以下参数以LinearSmoothScroller解释 * @param viewStart RecyclerView的top位置 * @param viewEnd RecyclerView的bottom位置 * @param boxStart Item的top位置 * @param boxEnd Item的bottom位置 * @param snapPreference 判断滑动方向的标识(The edge which the view should snap to when entering the visible * area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or * {@link #SNAP_TO_END}.) * @return 移动偏移量 */ @Override public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) { return boxStart - viewStart;// 这里是关键,得到的就是置顶的偏移量 } } } > RecyclerView平滑流畅的滑动到指定位置 Android开发:RecyclerView平滑流畅的滑动到指定位置- https://blog.csdn.net/Xiong_IT/article/details/78265549 RecyclerView 的smoothScrollToPosition()和scrollToPosition()不起效果 RecyclerView.scrollToPosition(position); RecyclerView.smoothScrollToPosition(position); -- RecyclerView滚动定位,解决方案如下: https://github.com/tyzlmjj/AndroidUI/blob/master/RecyclerViewLocation/app/src/main/java/com/mjj/recyclerviewlocation /MainActivity.java> RecyclerView更新或删除Item
notifyDataSetChanged();//通知重新绑定所有数据与界面 notifyItemChanged(int);//通知重新绑定某一个Item的数据与界面 notifyItemRangeChanged(int, int);//通知重新绑定某一范围内的的数据与界面