ImageCoverFlow
来源:互联网 发布:适合干性皮肤的水 知乎 编辑:程序博客网 时间:2024/06/05 10:41
介绍:
效果不错的画廊控件 可以设置画廊一次可见图片的张数,和其他第三方Gallery控件不同的是,该控件直接继承自View,而不是sdk中的Gallery控件。如果想获得包含demo的可运行代码,请在本站的下载链接中下载。
运行效果:
使用说明:
首先设置命名空间:
xmlns:imageCoverFlow="http://schemas.android.com/apk/res-auto"
在布局文件中添加ImageCoverFlow
<com.dolphinwang.imagecoverflow.CoverFlowView android:id="@+id/coverflow" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="20dp" android:paddingRight="20dp" imageCoverFlow:coverflowGravity="center_vertical" imageCoverFlow:coverflowLayoutMode="wrap_content" imageCoverFlow:reflectionGap="10dp" imageCoverFlow:reflectionHeight="30%" imageCoverFlow:visibleImage="3" > </com.dolphinwang.imagecoverflow.CoverFlowView>
注意作者在github上的描述是有问题的,没有
imageCoverFlow:enableReflection="true"和
imageCoverFlow:reflectionShaderEnable="true"
两个属性,作者根本就没有定义。
另外,visibleImage属性的值必须为基数,否则会报出异常,这个异常是作者有意抛出的。
在Activity中初始化:
package com.example.imagecoverflowdemo; import java.util.ArrayList; import com.dolphinwang.imagecoverflow.CoverFlowAdapter;import com.dolphinwang.imagecoverflow.CoverFlowView;import com.dolphinwang.imagecoverflow.CoverFlowView.CoverFlowGravity;import com.dolphinwang.imagecoverflow.CoverFlowView.CoverFlowLayoutMode; import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.os.Bundle;import android.support.v7.app.ActionBarActivity;import android.view.Menu;import android.view.MenuItem; public class MainActivity extends ActionBarActivity { private ArrayList<Bitmap> imgList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); CoverFlowView<MyCoverFlowAdapter> mCoverFlowView = (CoverFlowView<MyCoverFlowAdapter>)this.findViewById(R.id.coverflow); imgList = new ArrayList<Bitmap>(); imgList.add(BitmapFactory.decodeResource(this.getResources(), R.drawable.a)); imgList.add(BitmapFactory.decodeResource(this.getResources(), R.drawable.b)); imgList.add(BitmapFactory.decodeResource(this.getResources(), R.drawable.c)); imgList.add(BitmapFactory.decodeResource(this.getResources(), R.drawable.d)); imgList.add(BitmapFactory.decodeResource(this.getResources(), R.drawable.d)); MyCoverFlowAdapter adapter = new MyCoverFlowAdapter(); mCoverFlowView.setAdapter(adapter); } public class MyCoverFlowAdapter extends CoverFlowAdapter{ public int getCount(){ return 5; } public Bitmap getImage(int position){ return imgList.get(position); } } }
附上源码:http://download.csdn.net/detail/gsg8709/9389449
1 0
- ImageCoverFlow
- ImageCoverFlow
- 图片层叠并滚动效果的实现之ImageCoverFlow
- c中static静态变量与全局变量的区别
- 依次加载listview的每一个item实现动画的效果
- 关于vs2012按下键盘有提示但是按下enter不能选中所选提示
- [Android实例] MQTT消息推送,即时通讯
- 屏幕监听
- ImageCoverFlow
- 高效C编程(上) 基础数据类型,Loop,寄存器分配,函数调用,指针别名 ARM
- Android 快速开发系列 打造万能的ListView GridView 适配器
- Visual C++ Tips: 用 IP Helper 获得网络接口的友好名称(Friendly Name)
- JS----几种过滤重复的数组的方法
- 【项目练习】遇到的问题和解决方法
- 数据库设计步骤--了解用户需求:向客户请教
- window.location.reload();页面实现跳转和刷新
- 壳的编写(3)-- 编写壳(Stub)部分(2)