list: make fast scroll thumb less intrusive
This commit is contained in:
parent
be666069fc
commit
ecc8d8750a
4 changed files with 19 additions and 29 deletions
|
@ -72,8 +72,9 @@ class FastScrollRecyclerView
|
|||
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
|
||||
AuxioRecyclerView(context, attrs, defStyleAttr) {
|
||||
// Thumb
|
||||
private val thumbSize = context.getDimenPixels(R.dimen.size_touchable_small)
|
||||
private val slider = MaterialSlider(context, thumbSize)
|
||||
private val thumbWidth = context.getDimenPixels(R.dimen.spacing_mid_medium)
|
||||
private val thumbHeight = context.getDimenPixels(R.dimen.size_touchable_medium)
|
||||
private val slider = MaterialSlider(context, thumbWidth)
|
||||
private var thumbAnimator: Animator? = null
|
||||
|
||||
private val thumbView =
|
||||
|
@ -174,16 +175,16 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||
|
||||
thumbView.layoutDirection = layoutDirection
|
||||
thumbView.measure(
|
||||
MeasureSpec.makeMeasureSpec(thumbSize, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(thumbSize, MeasureSpec.EXACTLY))
|
||||
MeasureSpec.makeMeasureSpec(thumbWidth, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(thumbHeight, MeasureSpec.EXACTLY))
|
||||
val thumbTop = thumbPadding.top + thumbOffset
|
||||
val thumbLeft =
|
||||
if (isRtl) {
|
||||
thumbPadding.left
|
||||
} else {
|
||||
width - thumbPadding.right - thumbSize
|
||||
width - thumbPadding.right - thumbWidth
|
||||
}
|
||||
thumbView.layout(thumbLeft, thumbTop, thumbLeft + thumbSize, thumbTop + thumbSize)
|
||||
thumbView.layout(thumbLeft, thumbTop, thumbLeft + thumbWidth, thumbTop + thumbHeight)
|
||||
}
|
||||
|
||||
override fun onScrolled(dx: Int, dy: Int) {
|
||||
|
@ -233,8 +234,9 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||
|
||||
if (thumbView.isUnder(eventX, eventY, minTouchTargetSize)) {
|
||||
dragStartThumbOffset = thumbOffset
|
||||
} else if (eventX > thumbView.right - thumbSize / 4) {
|
||||
dragStartThumbOffset = (eventY - thumbPadding.top - thumbSize / 2f).toInt()
|
||||
} else if (eventX > thumbView.right - thumbWidth / 4) {
|
||||
dragStartThumbOffset =
|
||||
(eventY - thumbPadding.top - thumbHeight / 2f).toInt()
|
||||
scrollToThumbOffset(dragStartThumbOffset)
|
||||
} else {
|
||||
return false
|
||||
|
@ -252,7 +254,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||
dragStartThumbOffset = thumbOffset
|
||||
} else {
|
||||
dragStartY = eventY
|
||||
dragStartThumbOffset = (eventY - thumbPadding.top - thumbSize / 2f).toInt()
|
||||
dragStartThumbOffset =
|
||||
(eventY - thumbPadding.top - thumbHeight / 2f).toInt()
|
||||
scrollToThumbOffset(dragStartThumbOffset)
|
||||
}
|
||||
|
||||
|
@ -319,7 +322,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||
|
||||
private val thumbOffsetRange: Int
|
||||
get() {
|
||||
return height - thumbPadding.top - thumbPadding.bottom - thumbSize
|
||||
return height - thumbPadding.top - thumbPadding.bottom - thumbHeight
|
||||
}
|
||||
|
||||
/** An interface to provide text to use in the popup when fast-scrolling. */
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,840L300,660L358,602L480,724L602,602L660,660L480,840ZM358,362L300,304L480,124L660,304L602,362L480,240L358,362Z"/>
|
||||
</vector>
|
|
@ -3,9 +3,8 @@
|
|||
android:shape="rectangle"
|
||||
android:tint="?attr/colorSecondary">
|
||||
|
||||
<corners android:topLeftRadius="24dp" android:bottomLeftRadius="24dp" />
|
||||
<corners android:radius="8dp" />
|
||||
<size
|
||||
android:width="48dp"
|
||||
android:height="48dp" />
|
||||
android:width="4dp" />
|
||||
<solid android:color="@android:color/white" />
|
||||
</shape>
|
|
@ -2,14 +2,13 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/ui_scroll_thumb">
|
||||
android:padding="@dimen/spacing_tiny"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/size_touchable_small"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/size_touchable_small"
|
||||
app:tint="?attr/colorOnSecondary"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_scroll_24" />
|
||||
android:src="@drawable/ui_scroll_thumb" />
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in a new issue