PageIndicatorView
is light library to indicate PageSlider's selected page with different animations and ability to customise it as you need.
implementation 'io.openharmony.tpc.thirdlib:pageindicatorview:1.0.1'
Usage of PageIndicatorView
is quite simple. All you need to do is to declare a view in your layout.xml
and call setSelection
method to select specific indicator - that's it!
PageIndicatorView pageIndicatorView = (PageIndicatorView) findComponentById(ResourceTable.Id_piv);
pageIndicatorView.setCount(5); // specify total count of indicators
pageIndicatorView.setSelection(2);
But if you're as lazy as I'm - then there is another option to handle PageIndicatorView
<com.rd.PageIndicatorView
ohos:id="$+id:piv"
ohos:height="40vp"
ohos:width="200vp"
ohos:bottom_margin="48vp"
ohos:background_element="#fffffff"
ohos:layout_alignment="bottom|horizontal_center"
ohos:piv_padding="12dp"
ohos:piv_radius="8dp"/>
All the piv_
attributes here are specific for PageIndicatorView
so you can customise it as you want with attributes - pretty handy.
But what is more important here is ohos:piv_PageSlider="$+id:PageSlider"
.
What it actually do is catch up your PageSlider
and automatically handles all the event's to selected the right page - so you don't need to call setSelection
method on your own.
Another handy options here that works with your PageSlider
as a whole is
ohos:piv_dynamicCount="true"
and ohos:piv_interactiveAnimation="true"
Dynamic count will automatically updates PageIndicatorView
total count as you updates pages count in your PageSlider
- so that's pretty useful.
While interactive animation will progress the animation process within your swipe position, which makes animation more natural and responsive to end user.
Note: Because
setPageSliderId
uses an instance ofPageSlider
, using it in recycler could lead to id conflicts, soPageIndicatorView
will not know properly what is the rightPageSlider
to work with. Instead you should handle selected indicators on your own programatically.
pageSlider.addPageChangedListener(new PageSlider.PageChangedListener() {
@Override
public void onPageSliding(int position, float positionOffset, int positionOffsetPixels) {
pageIndicatorView.setSelection(position);
}
@Override
public void onPageSlideStateChanged(int i) {
}
@Override
public void onPageChosen(int i) {
}
});
Here you can see all the animations PageIndicatorView
support.
Name | Support version | Preview |
---|---|---|
AnimationType.NONE |
0.0.1 | ![]() |
AnimationType.COLOR |
0.0.1 | ![]() |
AnimationType.SCALE |
0.0.1 | ![]() |
AnimationType.SLIDE |
0.0.1 | ![]() |
AnimationType.WORM |
0.0.1 | ![]() |
AnimationType.FILL |
0.0.6 | ![]() |
AnimationType.THIN_WORM |
0.0.7 | ![]() |
AnimationType.DROP |
0.1.0 | ![]() |
AnimationType.SWAP |
0.1.1 | ![]() |
Copyright 2017 Roman Danylyk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )