运行效果:


使用说明:
youtube 视频 : https://www.youtube.com/watch?v=YsMnLJeouf8&feature=youtu.be 源码中包含视频,但是卡片内容只是普通视图,不是图片。
安装
-
下载 released .aar 文件 https://github.com/wenchaojiang/AndroidSwipeableCardStack/releases/download/0.1.1/android-card-stack-0.1.1.aar
-
把它放在项目的lib目录,比如“libs”
-
在gradle.build 文件中放入下面的代码:
Use jitpack
repositories { maven { url "https://jitpack.io" } } dependencies { compile 'com.github.wenchaojiang:AndroidSwipeableCardStack:0.*.*' }OR manually
-
Download released .aar file Download current release
-
put it into your project lib dir, "libs" for example.
-
put following lines to your gradle.build file
repositories { flatDir { dirs 'libs' } } dependencies { compile(name:'android-card-stack-0.1.0', ext:'aar') } -
在布局文件中放入CardStack
<com.wenchao.cardstack.CardStack
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding = "20dp"
android:clipChildren="false"
android:clipToPadding="false"
/>
Create your card view layout file.
Example: card_layout.xml, contain only a TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Implement your own adapter for the card stack. The CardStack will accept ArrayAdapter. The Following example extends a simple ArrayAdapter, overriding getView() to supply your customized card layout
public class CardsDataAdapter extends ArrayAdapter<String> {
@Override
public View getView(int position, final View contentView, ViewGroup parent){
//supply the layout for your card
TextView v = (TextView)(contentView.findViewById(R.id.content));
v.setText(getItem(position));
return contentView;
}
}