图片层叠并滚动效果的实现之ImageCoverFlow
2016-05-03 15:18
477 查看
需求是要有景深效果的图片轮番
1.注意设置命名空间:xmlns:app="http://schemas.android.com/apk/res-auto"
2.投射效果,加强了景深效果:app:reflectionHeight="30%"
3.当前可见的图片数,app:visibleImage="7",最低不能低于3
View
adapter的数据源是一组ArrayList<Bitmap>
CoverFlowView.java
修改缩放比例以达到图片重叠。
在drawChild方法中,给最顶上的图片加边框。通过drawBitmap在指定的位置画上去。
“没有好于不好,只有符不符合需求。”希望对你有帮助。
开源源码详见:https://github.com/dolphinwang/ImageCoverFlow
<com.koolsee.player.view.imagecoverflow.CoverFlowView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coverflow" android:layout_width="match_parent" android:layout_height="500dp" app:coverflowGravity="center_vertical" app:coverflowLayoutMode="match_parent" app:reflectionGap="10dp" app:reflectionHeight="30%" app:visibleImage="7" />
1.注意设置命名空间:xmlns:app="http://schemas.android.com/apk/res-auto"
2.投射效果,加强了景深效果:app:reflectionHeight="30%"
3.当前可见的图片数,app:visibleImage="7",最低不能低于3
View
CoverFlowView<MyCoverFlowAdapter> mCoverFlowView = (CoverFlowView<MyCoverFlowAdapter>) findViewById(R.id.coverflow);
adapter的数据源是一组ArrayList<Bitmap>
MyCoverFlowAdapter adapter = new MyCoverFlowAdapter(this, mResourceBitmaps);mCoverFlowView.setAdapter(adapter);
CoverFlowView.java
private void makeChildTransformer(Bitmap child, int mid, int position, float offset) { mChildTransformer.reset(); mReflectionTransformer.reset(); float scale = 0; //this scale make sure that each image will be smaller than the //previous one if (position != mid) { scale = 1 - Math.abs(offset) * 0.1f;//by.el 0.25 } else { scale = 1 - Math.abs(offset) * CARD_SCALE; }
修改缩放比例以达到图片重叠。
在drawChild方法中,给最顶上的图片加边框。通过drawBitmap在指定的位置画上去。
if(position == mid) { //draw middle border Rect rec = canvas.getClipBounds(); rec.bottom = wAndh[1] * 4 + 42; rec.right = wAndh[0] * 13 / 2 + 45; rec.top = -19; rec.left = wAndh[0] * 5 / 2 - 18; Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); Bitmap image = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.poster_sort_focus); canvas.drawBitmap(image, null, rec, paint); }
“没有好于不好,只有符不符合需求。”希望对你有帮助。
开源源码详见:https://github.com/dolphinwang/ImageCoverFlow
相关文章推荐
- 《android基于andFix的热修复方案》实战篇
- 域名地址默认跳转到www(301重定向)
- leetcode 319
- linux下安装MP4BOX
- 第十/十一周训练3-1protected
- java泛型(转自百度百科)
- 238. Product of Array Except Self
- nginx 日志管理
- iOS用全局宏的概念 preprocessor macros
- Volley使用时出现InterruptedIOException,NoConnectionError这样的问题
- Android Studio单元测试
- xml文件画线
- leetcode 168---Excel Sheet Column Title--- 为什么要--n?
- 将Cent0S 7的网卡名称eno16777736改为eth0
- u3d制作多米诺骨牌小游戏心得1
- win32创建一个线程
- VIM 分屏 过滤技巧 + source insight 快捷键
- POJ 1065 Wooden Sticks / hdu 1257 最少拦截系统 DP 贪心
- 第十/十一周训练2-3
- urlrewrite实现地址的重写