web coverflow的html5 源码,ImageCoverFlow

首先设置命名空间:xmlns:imageCoverFlow="http://schemas.android.com/apk/res-auto"

在布局文件中添加ImageCoverFlow

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" >

注意作者在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 imgList;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

CoverFlowView mCoverFlowView = (CoverFlowView)this.findViewById(R.id.coverflow);

imgList = new ArrayList();

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);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值