这个控件继承Gallery,图片之间有间隔,夜歌页面显示三张图,中间大,两边小
效果图:
(一、)上面的效果
源码参考:https://github.com/davidschreiber/FancyCoverFlow
将其中的library复制到自己的项目中
(二、)下面的效果
参考源码:https://github.com/LittleLiByte/GlFancyCoverFlow
代码几乎与上面的一样,只是FancyCoverFlow不一样
1、在xml中引用:
<com.ysn.test.customerviews.fancycoverflow.FancyCoverFlow
android:id="@+id/fancyConverFlow"
android:layout_width="match_parent"
android:layout_height="200dp"/>
<!--指定高度之后,代码中的setScaleDownGravity(0.5)才有效果-->
2、适配器必须继承FancyCoverFlowAdapter
如果在xml中没有给高度指定具体数值,则在getView中必须为item根布局设置LayoutParams,例如
WindowManager mn = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int screenWidth=mn.getDefaultDisplay().getWidth();
llyFancy.setLayoutParams(new FancyCoverFlow.LayoutParams(screenWidth*1/2+30,
ViewGroup.LayoutParams.WRAP_CONTENT));
3、代码中的设置适配器和点击事件,同listview