代码拉取完成,页面将自动刷新
本项目是基于开源项目EasyFlipView进行ohos化的移植和开发的,可以通过项目标签以及github地址( https://github.com/wajahatkarim3/EasyFlipView )追踪到原项目版本
方法1.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
……
}
方法2.
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
dependencies {
implementation 'com.wajahatkarim3.ohos:EasyFlipView:1.0.1'
}
layouts("Vertical")
<com.wajahatkarim3.easyflipview.EasyFlipView
ohos:width="match_parent"
ohos:height="match_content"
app:flipOnTouch="true"
app:flipEnabled="true"
app:flipDuration="400"
app:flipType="vertical"
app:flipFrom="front"
app:autoFlipBack="true"
app:autoFlipBackTime="1000"
>
<!-- Back Layout Goes Here -->
<Image
ohos:id="$+id:king_back_side"
ohos:height="500vp"
ohos:width="match_parent"
ohos:background_element="$media:back_side_king"
/>
<Image
ohos:id="$+id:king_front_side"
ohos:height="500vp"
ohos:width="match_parent"
ohos:background_element="$media:front_side_design"
/>
</com.wajahatkarim3.easyflipview.EasyFlipView>
layouts("Horizontal")
<com.wajahatkarim3.easyflipview.EasyFlipView
ohos:width="match_parent"
ohos:height="match_content"
app:flipOnTouch="true"
app:flipEnabled="true"
app:flipDuration="400"
app:flipFrom="right"
app:flipType="horizontal"
app:autoFlipBack="false"
>
<!-- Back Layout Goes Here -->
<Image
ohos:id="$+id:king_back_side"
ohos:height="500vp"
ohos:width="match_parent"
ohos:background_element="$media:back_side_king"
/>
<Image
ohos:id="$+id:king_front_side"
ohos:height="500vp"
ohos:width="match_parent"
ohos:background_element="$media:front_side_design"
/>
</com.wajahatkarim3.easyflipview.EasyFlipView>
// Flips the view with or without animation
mYourFlipView.flipTheView();
mYourFlipView.flipTheView(false);
// 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();
// Get current flip state in enum (FlipState.FRONT_SIDE or FlipState.BACK_SIDE)
EasyFlipView.FlipState flipSide = mYourFlipView.getCurrentFlipState();
// Get whether front/back side of flip is visible or not.
boolean frontVal = mYourFlipView.isFrontSide();
boolean backVal = mYourFlipView.isBackSide();
// Get/Set the FlipType to FlipType.Horizontal
boolean isHorizontal = mYourFlipView.isHorizontalType();
mYourFlipView.setToHorizontalType();
// Get/Set the FlipType to FlipType.Vertical
boolean isVertical = mYourFlipView.isVerticalType();
mYourFlipView.setToVerticalType();
// Get/Set if the auto flip back is enabled
boolean isAutoFlipBackEnabled = mYourFlipView.isAutoFlipBack();
mYourFlipView.setAutoFlipBack(true);
// Get/Set the time in milliseconds (ms) after the view is auto flip back to original front side
int autoflipBackTimeInMilliseconds = mYourFlipView.getAutoFlipBackTime();
mYourFlipView.setAutoFlipBackTime(2000);
// Sets the animation direction from left (horizontal) and back (vertical)
easyFlipView.setFlipTypeFromLeft();
// Sets the animation direction from right (horizontal) and front (vertical)
easyFlipView.setFlipTypeFromRight();
// Sets the animation direction from front (vertical) and right (horizontal)
easyFlipView.setFlipTypeFromFront();
// Sets the animation direction from back (vertical) and left (horizontal)
easyFlipView.setFlipTypeFromBack();
// Returns the flip type from direction. For horizontal, it will be either right or left and for vertical, it will be front or back.
easyFlipView.getFlipTypeFrom();
翻转动画监听:
EasyFlipView easyFlipView = (EasyFlipView) findViewById(R.id.easyFlipView);
easyFlipView.setOnFlipListener(new EasyFlipView.OnFlipAnimationListener() {
@Override
public void onViewFlipCompleted(EasyFlipView easyFlipView, EasyFlipView.FlipState newCurrentSide) {
ToastDialog toastDialog = new ToastDialog(getContext());
toastDialog.setText("Flip Completed! New Side is:"+ newCurrentSide).setDuration(1000).show();
}
});
定制化属性列表:
Attribute Name | Default Value | Description |
---|---|---|
app:flipOnTouch="true" | true | Whether card should be flipped on touch or not. |
app:flipDuration="400" | 400 | The duration of flip animation in milliseconds. |
app:flipEnabled="true" | true | If this is set to false, then it won't flip ever in Single View and it has to be always false for RecyclerView. |
app:flipType="horizontal" | vertical | Whether card should flip in vertical or horizontal. |
app:flipFrom="right" app:flipFrom="back" |
left front |
Whether card should flip from left to right Or right to left(Horizontal type) or car should flip to front or back(Vertical type). |
app:autoFlipBack="true" | false | If this is set to true, then he card will be flipped back to original front side after the time set in autoFlipBackTime. |
app:autoFlipBackTime="1000" | 1000 | The time in milliseconds (ms), after the card will be flipped back to original front side. |
Apache License, Version 2.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。