tommybuonomo / dotsindicator

Three material Dots Indicators for view pagers in Android !
Apache License 2.0
3.44k stars 353 forks source link

Indicators are not aligned properly when in LinearLayout with other content #119

Closed Nikola-Milovic closed 2 years ago

Nikola-Milovic commented 3 years ago

This is the desired result.

image

With this code

    <LinearLayout
        android:id="@+id/next_slides"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_marginTop="23dp"
        android:layout_marginBottom="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/welcome_user_viewPager">

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/skip_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:background="@android:color/transparent"
            android:text="SKIP"
            android:textColor="#C0C0C0"
            android:textSize="18sp" />

        <com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator
            android:id="@+id/spring_dots_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            app:dotsCornerRadius="8dp"
            app:dotsSize="16dp"
            app:dotsSpacing="4dp"
            app:dotsWidthFactor="2.5"
            app:progressMode="true" />

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/next_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:background="@android:color/transparent"
            android:text="NEXT"
            android:textSize="18sp"
            android:textStyle="bold" />

    </LinearLayout>

I am getting this

wrapContent

Now changing wrap content to match parent for the height results in a somewhat desirable result if the circles around the indicators would be in the correct place

incorrectPosition

tommybuonomo commented 2 years ago

Hello @Nikola-Milovic you just have to set a center gravity to your LinearLayout This is not a library issue