快速而简单的翻转视图 - EasyFlipView

2017-01-05      693      Android
项目简介

EasyFlipView

一个快速而简单的翻转视图,使用它你可以创建一个双面视图,比如信用卡,扑克等。

安装

在应用的build.gradle文件中添加:

dependencies {
  compile 'com.wajahatkarim3.EasyFlipView:EasyFlipView:1.0.0'
}

或者在pom.xml中将DBFlowManager作为一个新的依赖添加:

<dependency> 
  <groupId>com.wajahatkarim3.EasyFlipView</groupId>
  <artifactId>EasyFlipView</artifactId> 
  <version>1.0.0</version> 
  <type>pom</type> 
</dependency>

使用方法

XML

EasyFlipView In XML layouts

<com.wajahatkarim3.easyflipview.EasyFlipView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:flipOnTouch="true"
    app:flipEnabled="true"
    app:flipDuration="400">

    <!-- Back Layout Goes Here -->
    <include layout="@layout/flash_card_layout_back"/>

    <!-- Front Layout Goes Here -->
    <include layout="@layout/flash_card_layout_front"/>

</com.wajahatkarim3.easyflipview.EasyFlipView>

EasyFlipView的所有只定义属性

<declare-styleable name="easy_flip_view">
    <!-- Whether card should be flipped on touch or not (Default is true) -->
    <attr name="flipOnTouch" format="boolean"/>
    <!-- The duration of flip animation in milliseconds (Default is 400 ms) -->
    <attr name="flipDuration" format="integer"/>
    <!-- If this is set to false, then it won't flip ever (Default is true) -->
    <attr name="flipEnabled" format="boolean"/>
</declare-styleable>

代码中 (Java)

// Flips the view with animation
mYourFlipView.flipTheView();

// Sets and Gets the Flip Animation Duration in milliseconds (Default is 400 ms)
mYourFlipView.setFlipDuration(1000);
int dur = mYourFlipView.getFlipDuration();

// Sets and gets the flip enable status (Default is true)
mYourFlipView.setFlipEnabled(false);
boolean flipStatus = mYourFlipView.isFlipEnabled();

// Sets and gets the flip on touch status (Default is true)
mYourFlipView.setFlipOntouch(false);
boolean flipTouchStatus = mYourFlipView.isFlipOnTouch();