From 2d44ba8fe0ee818082527ec127e34797db052a6a Mon Sep 17 00:00:00 2001 From: Amirhosein Barati Date: Thu, 9 Mar 2023 21:00:02 +0330 Subject: [PATCH] add text appearance option to A3SeekBar.kt --- app/src/main/res/layout/activity_main.xml | 5 ++- .../java/ir/am3n/needtool/views/A3SeekBar.kt | 35 +++++++++++++------ .../src/main/res/layout/layout_a3seekbar.xml | 6 ++-- needtool/src/main/res/values/attrs.xml | 1 + 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cd2cd5d..42e4ea8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -35,8 +35,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/baseline_access_time_24" - android:text="text 1" android:drawablePadding="8dp" + android:text="text 1" app:a3_direction="locale" /> Unit = { bar, position -> val fill = if (isVertical) bar.measuredHeight else bar.measuredWidth - when { + progress = when { position in 1 until fill -> { - progress = if (isReverse) + if (isReverse) maxValue - (position * maxValue / fill) else minValue + (position * maxValue / fill) } - position <= 0 -> progress = if (isReverse) maxValue else minValue - position >= fill -> progress = if (isReverse) minValue else maxValue + position < 1 -> if (isReverse) maxValue else minValue + else -> if (isReverse) minValue else maxValue } } barCardView.setOnTouchListener { bar, event -> diff --git a/needtool/src/main/res/layout/layout_a3seekbar.xml b/needtool/src/main/res/layout/layout_a3seekbar.xml index c40bdb6..1482abd 100644 --- a/needtool/src/main/res/layout/layout_a3seekbar.xml +++ b/needtool/src/main/res/layout/layout_a3seekbar.xml @@ -39,7 +39,7 @@ android:layout_gravity="center" android:contentDescription="@null" /> - - - +