tommybuonomo / dotsindicator Goto Github PK
View Code? Open in Web Editor NEWThree material Dots Indicators for view pagers in Android !
License: Apache License 2.0
Three material Dots Indicators for view pagers in Android !
License: Apache License 2.0
Hi,
Why the lib does not support API 15?
There only 1 line of code to adjust.
Regards,
Soufiane.
For now I can specify only one color in DotsIndicator. How can I set different color for inactive dots.
I am using the WormsDotIndicator
<com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator
android:id="@+id/pager_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:dotsColor="@color/pink"
app:dotsStrokeColor="@color/lessPink"
app:dotsCornerRadius="10dp"
app:dotsSize="10dp"
app:dotsSpacing="6dp"
app:dotsWidthFactor="2.5"
/>
When on the last page the filled dot seems to be a bit out of the stroke circle
Hello, the id of the ImageView :
should be
Is there a way to use square/rectangle icon instead of circle? Any help would be appreciated. Thanks!
How can I change the background color inside the circle ?
I have 2 items in my viewpager and the dots indicator initialises with 3 dots
I can't see why - but if is set the viewpager to the second page then it initialises with 2 dots.
i think the problem is that in refreshDots() you call buildDot which adds a child view (dot) to the layout - if dotIndicatorView is not initialised.
You need to remove this view after you find that the viewpager adapter has pages - in that same refreshDots() method
I'm trying to disable the click on the DotIndicator so that the viewpager does not swipe anymore when I click on the dot. Help please !
Is there a way to widen the space between the dots so they arnt all crunched up together?
see versions at https://bintray.com/tbuonomo/maven/dots-indicator
and you version badge
I try to set indicator color by code "setDotIndicatorColor(color)" but i see that it crash becase in SpringDotsIndicator method "setUpDotBackground" you have:
GradientDrawable dotBackground = (GradientDrawable) dotView.getBackground();
but dotBackground is null and then crash in "dotBackground.setColor(dotIndicatorColor); "
Hi, great library. This there a way to add this:
Don't show indicator if adapter getcount() == 1
In my case I have a view pager adapter and every item is clickable opening another activity. In my list I only have 2 items. When I swipe to the second, click on it (opens the activity), and then finish the activity, the dots show wrong. While, it should show the second as selected, it shows the first one as selected.
DotsIndicator ----> interval clicks dots width bug
For view pager adapter extended from FragmentPagerAdapter, when we override its getPageWidth method and return lets say 0.5f or 0.7f or anything, then on page scrolling of viewpager, dots indicator starts to show multiple selected dots, on random scrolling. in my case i had 4 dots available, mostly issue is with last dot, it also gets selected
I don't see any notifyDataSetChanged() method that updates items in dotsIndicator adapter ?
When i add new item in my main viewpager adapter my app get crash. See below logs
10.09.19 14:57
Version: 1.0.43 (1043tackTrace)
Thread[main,5,main]
Exception: java.lang.ArrayIndexOutOfBoundsException
Message: length=10; index=-1
Stacktrace:
java.util.ArrayList.get(ArrayList.java:439)
com.tbuonomo.viewpagerdotsindicator.SpringDotsIndicator$buildOnPageChangedListener$1.onPageScrolled$viewpagerdotsindicator_release(SpringDotsIndicator.kt:161)
com.tbuonomo.viewpagerdotsindicator.OnPageChangeListenerHelper.onPageScrolled(OnPageChangeListenerHelper.kt:17)
com.tbuonomo.viewpagerdotsindicator.BaseDotsIndicator$setViewPager$2$addOnPageChangeListener$1.onPageScrolled(BaseDotsIndicator.kt:218)
androidx.viewpager.widget.ViewPager.dispatchOnPageScrolled(ViewPager.java:1930)
androidx.viewpager.widget.ViewPager.onPageScrolled(ViewPager.java:1904)
androidx.viewpager.widget.ViewPager.pageScrolled(ViewPager.java:1842)
androidx.viewpager.widget.ViewPager.completeScroll(ViewPager.java:1988)
androidx.viewpager.widget.ViewPager.scrollToItem(ViewPager.java:692)
androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:670)
androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:631)
androidx.viewpager.widget.ViewPager.dataSetChanged(ViewPager.java:1086)
androidx.viewpager.widget.ViewPager$PagerObserver.onChanged(ViewPager.java:3097)
androidx.viewpager.widget.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:291)
I'm using the WormDotsIndicator
My App is only in English but I have supportRtl=true in my manifest
When the device is in an RTL language the the view isn't visible (Although I can see it's taking the correct space when I do "Show layout bounds" on the device
Error:(117) error: attribute 'com.sdkhightech.gocardpro:dotsStrokeColor' not found.
Can I change the colors to pictures?OR Can I change color to R.drawable?
thank you
I have 7 fragments in adapter. On moving to 5th step, sometimes it shows 4th and 5th both step indicators selected. It not happens every time.
error: failed linking file resources.
android error : Message{kind=ERROR, text=error: attribute 'com.example.shreyash.myapplication:dotsCornerRadius' not found., sources=[C:\Users\Shreyash\AndroidStudioProjects\MyApplication\app\src\main\res\layout\fragment_board.xml:472], original message=, tool name=Optional.of(AAPT)}
Is there any way to set the indicator according to the recycler view?
Is this library compatible with ViewPager2?
Error:(9, 5) error: resource android:attr/dialogCornerRadius not found.
Error:(1234, 5) error: resource android:attr/fontVariationSettings not found.
Error:(1234, 5) error: resource android:attr/ttcIndex not found.
Currently the worm dot indicator gets cut off at the end if there are more view pager items then can fit in the width of the dot indicator. Can you wrap the dots or maybe stay on the middle dot until it make sense to start scrolling to the last dot again?
I am using SpringDotsIndicator
but in my gallery I have more then 20 images and the dots doesn't resize automatically.
Any solutions?
I tried to add SpringDotsIndicator
inside an horizontal ScrollView
but nothing.
Hello,
I am using your library in order to do a pop up screen containing a stepper in my android application.
I am able to close pop up whatever step I am.
if I click to a close icon, I collapse my pop up screen and I reset my view pager to beginning( to index zero).
When I open again my pop up screen, viewpager is correctly to first step but I have two dots with active color.
How can I reset the active dot first one when I resetting the viewpager to the beginning in the same time?
java.lang.NoClassDefFoundError: android/support/animation/SpringAnimation at com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator.setUpDotIndicator(WormDotsIndicator.java:133) at com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator.refreshDots(WormDotsIndicator.java:105) at com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator.onAttachedToWindow(WormDotsIndicator.java:100) at android.view.View.dispatchAttachedToWindow(View.java:18347) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
When the view with the viewpager is created a dot is seen as below the other dots.
Can you replicate this ? Can you fix it ?
Thanks
*Update target SDK.
I'm wondering why the library needs to implement the cardview library. I don't see it being used anywhere in the project.
English layout working fine, but when changing the language into Arabic it showing only one dots
I'm trying to increasing the size of unselected dots little bit almost half of selected dot. Can you please share me the way to do this?
Steps to reproduce:
Viewpaper + WormDotsIndicator
I have used this in an app where i update the adapter in OnResume(). I navigate between the main activity and another activity, and back again. Without the dotsindicator, everything is fine.
When i add the dotsindicator, i hit a performance issue which gets worse and worse the more times i call adapter.notifyDataSetChanged(). Using the android performance profiler i can see that the DotsIndicator is calling setUpDots() over and over again.
Like i said the problem becomes worse and worse the more times i call adapter.notifyDataSetChanged() untill the app finally crashes.
Hello, the dotsStrokeColor is not setted on setStrokeDotsIndicatorColor(int color)
like on setDotIndicatorColor(int color)
(Same thing on SpringDotsIndicator.java)
Unlike viewpager, for viewpager2, the onPageScrolled handler is called when the view is first rendered. However, the following code snippet assumes there will always be a next page. This causes an index out of range exception crash.
This is happening for v4.1.1
fun onPageScrolled(position: Int, positionOffset: Float) {
var offset = (position + positionOffset)
val lastPageIndex = (pageCount - 1).toFloat()
if (offset == lastPageIndex) {
offset = lastPageIndex - .0001f
}
val leftPosition = offset.toInt()
val rightPosition = leftPosition + 1 <-- lastPageIndex is taken into account, but right position is still assumed to be left + 1 even when left and right are the same position for a 1 page viewpager
onPageScrolled(leftPosition, rightPosition, offset % 1)
if (lastLeftPosition != -1) {
if (leftPosition > lastLeftPosition) {
(lastLeftPosition until leftPosition).forEach {
resetPosition(it)
}
}
if (rightPosition < lastRightPosition) {
resetPosition(lastRightPosition)
((rightPosition + 1)..lastRightPosition).forEach {
resetPosition(it)
}
}
}
lastLeftPosition = leftPosition
lastRightPosition = rightPosition
}
Specifically the crash happens on this line.
override fun onPageScrolled(selectedPosition: Int, nextPosition: Int, positionOffset: Float) {
val x = (dots[selectedPosition].parent as ViewGroup).left.toFloat()
val nextX = (dots[if (nextPosition == -1) selectedPosition else nextPosition].parent as ViewGroup).left <--- dots[nextPosition] is now left position + 1 which is out of range.
.toFloat()
val xFinalPosition: Float
val widthFinalPosition: Float
when (positionOffset) {
in 0.0f..0.1f -> {
xFinalPosition = x
widthFinalPosition = dotsSize
}
in 0.1f..0.9f -> {
xFinalPosition = x
widthFinalPosition = nextX - x + dotsSize
}
else -> {
xFinalPosition = nextX
widthFinalPosition = dotsSize
}
}
dotIndicatorXSpring?.animateToFinalPosition(xFinalPosition)
dotIndicatorWidthSpring?.animateToFinalPosition(widthFinalPosition)
}
When I execute DotsIndicator dotsIndicator = findViewById(R.id.dots_indicator_view_pager_insights);
, getting an error message straight away
DotsIndicator: You have to set an adapter to the view pager before !
I do set the adapter right after the findViewById
, shouldn't the message appear later on, if no adapter has yet been set?
cant find this ViewPagerAdapder
Hey there, first of all very nice work.
I want to make the selected dot wider (just like in Dots Indicator) for worm or Spring Indicator
Alternatively,
you can provide un_selected_dot_background_color for DotsIndicator
That'll make it perfect.
Thanks
I am trying to show a view pager with bottom sheet view effect . Where a person swipes up and the view pager is visible. But when i am adding dot indicator .
The bottom sheet behaviour is capturing the swipe effect and its collapsing my view pager to half the view size and sometimes when i am trying to swipe the view pager the views disappear from bottom view also .
Its a serious bug When using with bottom sheet view.
`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"
android:id="@+id/bottom_sheet_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical"
app:behavior_hideable="true"
app:behavior_peekHeight="100dp"
app:layout_behavior="@string/bottom_sheet_behavior"
tool:behavior_peekHeight="300dp">
<include
android:id="@+id/topBar"
layout="@layout/partial_top_bar"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginBottom="10dp"
android:background="@drawable/back_transparent_gradient" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager_view"
android:layout_width="match_parent"
android:layout_height="321dp"
android:layout_gravity="bottom"
android:background="@drawable/back_transparent_gradient"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingStart="@dimen/card_left_padding"
android:paddingLeft="@dimen/card_left_padding"
android:paddingEnd="@dimen/card_right_padding"
android:paddingRight="@dimen/card_right_padding"/>
<com.tbuonomo.viewpagerdotsindicator.DotsIndicator
android:id="@+id/dots_indicator_"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_bar"
android:background="@color/colorPrimaryDark"
app:dotsColor="@color/medGrey"
android:gravity="center"
android:layout_gravity="center"
app:selectedDotColor="@color/white"
app:dotsCornerRadius="8dp"
app:dotsSize="6dp"
app:dotsSpacing="4dp"
app:dotsWidthFactor="2.5"
/>
</LinearLayout>
The main activity code remains the same . adding a view pager in the dot indicator .
All three types of indicators never appear on the screen.
implementing according to the git doc.
xml and java files attached here.
indicators.zip
when I want to implement it its say AAPT2 error before building
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.