代码拉取完成,页面将自动刷新
本项目是基于开源项目 SwipePanel 进行ohos化的移植和开发的,可以通过项目标签以及github地址(https://github.com/Blankj/SwipePanel )追踪到原项目版本
方法1.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
……
}
方法2.
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
dependencies {
implementation 'com.blankj.ohos:swipe-panel:1.0.0'
}
代码使用
final SwipePanel swipePanel = new SwipePanel(this);
swipePanel.setLeftEdgeSize(AttrHelper.vp2px(100, getContext()));// 设置左侧触发阈值 100dp
swipePanel.setLeftDrawable(ResourceTable.Media_base_back);// 设置左侧 icon
swipePanel.wrapView(findComponentById(ResourceTable.Id_rootLayout));// 设置嵌套在 rootLayout 外层
swipePanel.setOnFullSwipeListener(new SwipePanel.OnFullSwipeListener() {// 设置完全划开松手后的监听
@Override
public void onFullSwipe(int direction) {
terminateAbility();
swipePanel.close(true);// 关闭
}
});
swipePanel.setOnProgressChangedListener(new SwipePanel.OnProgressChangedListener() {
@Override
public void onProgressChanged(int direction, float progress, boolean isTouch) {
HiLog.error(LABEL, "" + progress);
}
});
xml使用
<?xml version="1.0" encoding="utf-8"?>
<com.blankj.swipepanel.SwipePanel
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.ohos.com/apk/res-auto"
ohos:id="$+id:swipePanel"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="$color:mediumGray"
app:bottomDrawable="$media:icon"
app:bottomEdgeSize="100vp"
app:bottomSwipeColor="$color:colorAccent"
app:isBottomCenter="true"
app:isLeftCenter="false"
app:isRightCenter="false"
app:isTopCenter="true"
app:leftDrawable="$media:base_back"
app:leftEdgeSize="100vp"
app:leftSwipeColor="$color:colorPrimary"
app:rightDrawable="$media:base_back"
app:rightEdgeSize="100vp"
app:rightSwipeColor="$color:colorPrimary"
app:topDrawable="$media:icon"
app:topEdgeSize="100vp"
app:topSwipeColor="$color:colorAccent">
<DependentLayout
ohos:height="match_parent"
ohos:width="match_parent">
</DependentLayout>
</com.blankj.swipepanel.SwipePanel>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。