• 微信号:Zh-y9213
您当前的位置:爱资源分享网 > > 网站源码 > 程序源码

类似社交app tinder的滑动卡片效果安卓源码下载

栏目:程序源码时间:2021-11-18 14:13阅读数:73人阅读
介绍:类似社交app tinder的滑动卡片效果安卓源码,流畅,体验很好。可以用来实现滑到左边喜欢,右边不喜欢之类的功能,卡片内容的添加是用的Adapter。
运行效果:

使用说明: 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

    1. Download released .aar file Download current release

    2. put it into your project lib dir, "libs" for example.

    3. 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;
    }

}


资源均来自第三方,谨慎下载,前往第三方网站下载

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:737597453@qq.com