Display hue slider

This commit is contained in:
Moez Bhatti
2018-03-24 04:48:11 -04:00
parent 63070609bd
commit 640a7b0109
2 changed files with 18 additions and 0 deletions
@@ -20,6 +20,7 @@ package feature.themepicker
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.support.constraint.ConstraintLayout import android.support.constraint.ConstraintLayout
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
@@ -32,6 +33,9 @@ import kotlinx.android.synthetic.main.hsv_picker_view.view.*
class HSVPickerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) { class HSVPickerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) {
private val hues = arrayOf(0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF0000)
.map { it.toInt() }.toIntArray()
private var min: Float = 0f private var min: Float = 0f
private var max = 0f private var max = 0f
@@ -72,6 +76,9 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
} }
true true
} }
hueBackground.clipToOutline = true
hueBackground.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
} }
private fun setupBounds() { private fun setupBounds() {
@@ -46,8 +46,19 @@
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:padding="2dp" android:padding="2dp"
android:src="@drawable/circle" android:src="@drawable/circle"
tools:tint="@color/tools_theme" /> tools:tint="@color/tools_theme" />
<ImageView
android:id="@+id/hueBackground"
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginTop="24dp"
android:background="@drawable/rounded_rectangle_2dp"
app:layout_constraintEnd_toEndOf="@id/saturation"
app:layout_constraintStart_toStartOf="@id/saturation"
app:layout_constraintTop_toBottomOf="@id/saturation" />
</merge> </merge>