5 Star 2 Fork 1

HarmonyOS-TPC / slideview

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

SlideView

A simple, yet awesome sliding button for openharmony.

Preview

image1 image2

Usage

dependencies{
   implementation 'io.openharmony.tpc.thirdlib:slideview:1.0.1'
}

The SlideView is very easy to use. Just add it to your layout like any other Component.

Via XML

Here's a basic implementation.

 <ng.max.slideview.SlideView
         ohos:id="$+id:view_slider_one"
         ohos:width="match_parent"
         ohos:height="match_content"
         ohos:top_margin="20vp"

         app:sv_buttonBackgroundColor="#fff"
         app:sv_buttonImage="$media:ic_chevron_double_right_pink"
         app:sv_slideBackgroundColor="$color:colorAccent"
         app:sv_slideText="Accept"
         />

Here's an example with all the view attributes.

<ng.max.slideview.SlideView
        ohos:width="match_parent"
        ohos:height="match_content"
        ohos:top_margin="20vp"
        app:sv_slideBackgroundColor="$color:slide_bg_color"
        app:sv_buttonBackgroundColor="$color:button_bg_color"
        app:sv_buttonImage="$media:ic_settings_purple"
        app:sv_slideText="Enabled"
        app:sv_slideTextColor="$color:slide_text_color"
        app:sv_slideTextSize="16fp"
        app:sv_animateSlideText="true"
        app:sv_reverseSlide="true"
        app:sv_strokeColor="$color:slide_stroke_color"
        app:sv_buttonImageDisabled="$media:ic_settings_grey600_24dp"
        />

AttrSet information

AttrSet name Description Default value
slideBackgroundColor The slide background color #3F51B5
buttonBackgroundColor The slide button background color #FFFFFF
slideTextColor The color of the slide label #FFFFFF
buttonImage The drawable on the button double chevron icon
slideText The slide label none
slideTextSize The label's size 16fp
animateSlideText If true, the label fades out while the slide is in progress true
strokeColor If set, a stroke is drawn around the slide background none
reverseSlide If true, the SlideView is reversed false
buttonImageDisabled The element to be used as the button image when the SlideView is disabled the default element

Listening for slide actions on the SlideView

You can set a listener to be notified when the user slides across the SlideView. An example is shown below.

SlideView  slideView_one= (SlideView)findComponentById(ResourceTable.Id_slider1);
slideView_one.setOnSlideCompleteListener(new SlideView.OnSlideCompleteListener() {
                      @Override
                      public void onSlideComplete(SlideView slideView) {

                      }
                  });

Setting the view attrSet via code

For convenience, many of the SlideView attrSet can be set via code.

 // set the label
 setText(String text);
 
 // set the text size
 setTextSize(int size);
 
 // set the Element for the button
 setButtonImage(Element image);
 
 // set the label color
 setTextColor(int color) ;

 // set the button element for disabled state
 setButtonImageDisabled(Element image);
 
 // set the button background color
 setButtonBackgroundColor(int color);
 
 // set the slide background color
 setSlideBackgroundColor(int color);
 

License

Copyright (c) 2017 MAXDeliveryNG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The MIT License (MIT) Copyright (c) 2017 MAXDeliveryNG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A simple, yet awesome sliding button for openharmony. 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/HarmonyOS-tpc/slideview.git
git@gitee.com:HarmonyOS-tpc/slideview.git
HarmonyOS-tpc
slideview
slideview
master

搜索帮助