mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 13:48:52 +01:00
Add thumb for hue slider
This commit is contained in:
@@ -77,6 +77,23 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hueThumbX = 0f
|
||||||
|
|
||||||
|
hueBackground.setOnTouchListener { _, event ->
|
||||||
|
when (event.action) {
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
hueThumbX = event.x - event.rawX
|
||||||
|
}
|
||||||
|
|
||||||
|
MotionEvent.ACTION_MOVE -> {
|
||||||
|
hueThumb.x = (event.rawX + hueThumbX + hueThumb.width / 2).within(0f, width - hueThumb.width.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> return@setOnTouchListener false
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
hueBackground.clipToOutline = true
|
hueBackground.clipToOutline = true
|
||||||
hueBackground.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
hueBackground.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,19 +46,37 @@
|
|||||||
android:layout_width="16dp"
|
android:layout_width="16dp"
|
||||||
android:layout_height="16dp"
|
android:layout_height="16dp"
|
||||||
android:background="@drawable/circle"
|
android:background="@drawable/circle"
|
||||||
android:elevation="2dp"
|
android:elevation="4dp"
|
||||||
android:padding="2dp"
|
android:padding="2dp"
|
||||||
android:src="@drawable/circle"
|
android:src="@drawable/circle"
|
||||||
tools:tint="@color/tools_theme" />
|
tools:tint="@color/tools_theme" />
|
||||||
|
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/hueBackground"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="2dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:clipToPadding="false"
|
||||||
android:background="@drawable/rounded_rectangle_2dp"
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@id/saturation"
|
app:layout_constraintEnd_toEndOf="@id/saturation"
|
||||||
app:layout_constraintStart_toStartOf="@id/saturation"
|
app:layout_constraintStart_toStartOf="@id/saturation"
|
||||||
app:layout_constraintTop_toBottomOf="@id/saturation" />
|
app:layout_constraintTop_toBottomOf="@id/saturation">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/hueBackground"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="@drawable/rounded_rectangle_2dp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/hueThumb"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:background="@drawable/circle"
|
||||||
|
android:elevation="4dp"
|
||||||
|
tools:tint="@color/tools_theme" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
Reference in New Issue
Block a user