Scrollview&RecycleView&ListView&Viewpager的顶部/底部阴影颜色改变
2018-02-08 19:35
627 查看
Scrollview&RecycleView&ListView&Viewpager的顶部/底部阴影颜色改变
0 利用主题设置
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent"< 4000 /span>>@color/colorAccent</item> <item name="android:colorEdgeEffect">@color/colorAccent</item> </style>
但是注意,只能在api21以上设置
以下的方法为反射设置
1 Scrollview
牵扯到的两个属性mEdgeGlowTop,
mEdgeGlowBottom,都为
EdgeEffect类型
直接去反射改变颜色
这里以
mEdgeGlowTop为例
Field topMethod = ScrollView.class.getDeclaredField("mEdgeGlowTop"); topMethod.setAccessible(true); EdgeEffect top = (EdgeEffect) topMethod.get(scrollView); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { top.setColor(Color.RED); }
2 RecycleView
RecycleView有4个属性,
mLeftGlow, mTopGlow, mRightGlow, mBottomGlow
采用和
Scrollview同样的方式既可以做到
3 ListView
listview是有一个public的方法的
/** * Sets the drawable that will be drawn above all other list content. * This area can become visible when the user overscrolls the list. * * @param header The drawable to use */ public void setOverscrollHeader(Drawable header) { mOverScrollHeader = header; if (mScrollY < 0) { invalidate(); } } /** * Sets the drawable that will be drawn below all other list content. * This area can become visible when the user overscrolls the list, * or when the list's content does not fully fill the container area. * * @param footer The drawable to use */ public void setOverscrollFooter(Drawable footer) { mOverScrollFooter = footer; invalidate(); }
4 viewpager
Viewpager同样有两个属性,是左右的,反射方式同样适用
Scrollview的,属性为
mLeftEdge,
mRightEdge
相关文章推荐
- android listview/ScrollView 去除顶部下拉时的半月形阴影和上下滑动顶部和底部的虚化
- 如何去掉滑动控件(比如ScrollView、ListView、ViewPager等)滑动到最顶部或最底部时出现的阴影效果。
- ListView和GridView,ViewPager滑动到顶部和底部时出现的阴影消除方法
- android listview/ScrollView 去除顶部下拉时的半月形阴影和上下滑动顶部和底部的虚化
- 禁用滚动视图ListView、ViewPager、ScrollView、HorizontalScrollView、WebView边界颜色渐变
- ScrollView/ListView 如何去掉下拉到顶部时出现的黑色阴影
- Android ScrollView嵌套Viewpager嵌套ListView切换时到顶部或位置改变问题解决
- 去除listView和recyclerview滑动到顶部和底部边界的阴影
- 禁用滚动视图ListView、ViewPager、ScrollView、HorizontalScrollView、WebView边界颜色渐变
- 除去ScrollVIew ListView Viewpager拉到尽头时再拉的阴影效果
- 首页-底部&顶部Tab导航(菜单栏)的实现:TabLayout+ViewPager+Fragment
- Android开发:顶部&底部Tab导航栏实现(TabLayout+ViewPager+Fragment)
- ScrollView ViewPager ListView三者共存
- viewpager和fragment结合实现碎片切换,改变字体颜色
- Scrollview中嵌套ViewPager中嵌套ListView 滑动中tab固定顶部ScrollingTricks效果特效
- 关于Android滑动控件顶部与底部阴影块的颜色替换
- android 滑动冲突 ScrollView Viewpager listview 等
- Android 用 TabLayout + ViewPager + Fragment 实现顶部、底部导航栏
- ListView /ScrollVIew 滑动出现阴影(白色或者黑色)
- 不但要返回顶部,还要返回底部,小改变,实用,?scroll?的js代码,支持IE,FF,chrome[摘自布布分享,tech.bubufx.com]