MaterialScrollBar
MaterialScrollBar copied to clipboard
Doesn't work with Constraint Layout
I even set it up with a regular RelativeLayout and converted it. Nothing works in Constraint Layout
RelativeLayout version:
<RelativeLayout 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.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>
The same issue too(
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