Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Constraint Layout #110

Open
easycheese opened this issue Jan 1, 2018 · 2 comments
Open

Doesn't work with Constraint Layout #110

easycheese opened this issue Jan 1, 2018 · 2 comments

Comments

@easycheese
Copy link

I even set it up with a regular RelativeLayout and converted it. Nothing works in Constraint Layout

RelativeLayout version:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.turingtechnologies.materialscrollbar.DragScrollBar
    android:id="@+id/dragScrollBar"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:msb_recyclerView="@id/recycler"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    app:msb_lightOnTouch="true"
    app:msb_handleColor="@color/colorAccent"
    app:msb_barColor="@color/colorAccent"
    />

<TextView
    android:id="@+id/empty_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:text="@string/no_data_found"
    android:textSize="20sp"
    tools:visibility="visible"
    android:layout_centerInParent="true"
    android:visibility="gone" />

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_add_white_24dp" />
</android.support.design.widget.CoordinatorLayout>

ConstraintLayout

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.companionfree.kdmgenerator.main.MainActivity"
android:id="@+id/relativeLayout">

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"/>

<com.turingtechnologies.materialscrollbar.DragScrollBar
    android:id="@+id/dragScrollBar"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:msb_recyclerView="@id/recycler"
    app:msb_lightOnTouch="true"
    app:msb_handleColor="@color/colorAccent"
    app:msb_barColor="@color/colorAccent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintRight_toRightOf="parent"/>

<TextView
    android:id="@+id/empty_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:text="@string/no_data_found"
    android:textSize="20sp"
    tools:visibility="visible"
    android:visibility="gone"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"/>

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_add_white_24dp" />
</android.support.design.widget.CoordinatorLayout>

</android.support.constraint.ConstraintLayout>

@GolubRoman
Copy link

The same issue too(

@Hartie95
Copy link

Hartie95 commented Oct 4, 2018

I have this issue too.
To let it the scroolbar show up when using a contraint layout I'm set the following in the XML Definition of the scrollbar:

android:layout_width="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent"

But with only this the indicator will be on the left side of the screen so I set an id to the indicator view and added a contraint for it in the linkToScrollBar method if the parent is a contraint layout:

if( msb.getParent() instanceof ConstraintLayout) {
            ConstraintLayout constraintLayout = (ConstraintLayout) msb.getParent();
            ConstraintSet constraintSet = new ConstraintSet();
            constraintSet.clone(constraintLayout);
            constraintSet.connect(getId(), ConstraintSet.END, materialScrollBar.getId(), ConstraintSet.START,size/2);
            constraintSet.applyTo(constraintLayout);
        }

This is probably just a workaround, but it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants