Code Monkey home page Code Monkey logo

cardswitch's Introduction

Android cardswitch 自定义控件

@Author : suzhiwei

简要说明:

CardSwitch 控件 为图片切换特效控件

开发此控件时同步录制的视频教程:http://pan.baidu.com/s/1hrmN2ew

image

使用 方法:

1.在xml layout 布局文件中引用:

<com.szw.cradswitch.CardView
android:id="@+id/cardview"
android:layout_width="500dip"
android:layout_height="500dip"
android:layout_centerInParent="true"
android:clipChildren="false"></com.szw.cradswitch.CardView>
  1. 在代码中需要设置adapter
//1.找到控件
CardView cardView = (CardView) this.findViewById(R.id.cardview);
//2 .创建一个adapter 继承CardViewAdapter
adapter = new MyCardView(getApplicationContext());
//3.填写 data 数据类型为 List<T> T为泛型
adapter.setData(initData());
//4. 设置adapter
cardView.setAdapter(adapter);
//5. 设置adapter 切换监听器
cardView.setCardClickListener(new CardClickListener() {
@Override
public void onClick(View view, int pos) {
// TODO Auto-generated method stub
android.widget.Toast.makeText(getApplicationContext(), pos + "", 1).show();
}
});

3 其他API

// 设置 cardView 的最大卡片层叠数量 默认为3 
cardView.setmMaxCardSize(4);
// 设置 cardView 的卡片间距  默认为20px (建议项目中 用dp,动态转换为px 传入) 
cardView.setItemSpace(20);

cardswitch's People

Contributors

littlefishwill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.