Skip to content

Commit 6d41cca

Browse files
committed
feat: Add stroke alpha control
Adds a SeekBar to control the stroke alpha property.
1 parent 3c1cf5f commit 6d41cca

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

app/src/main/java/com/sonsation/shadowlayout/MainActivity.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,25 @@ class MainActivity : AppCompatActivity() {
413413
})
414414
}
415415

416+
bind.strokeAlphaSeekbar.apply {
417+
min = 0
418+
max = 100
419+
setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
420+
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
421+
shadowLayout.updateStrokeAlpha(progress)
422+
bind.strokeAlphaValue.text = "${progress}"
423+
}
424+
425+
override fun onStartTrackingTouch(seekBar: SeekBar?) {
426+
427+
}
428+
429+
override fun onStopTrackingTouch(seekBar: SeekBar?) {
430+
431+
}
432+
})
433+
}
434+
416435
bind.strokeBlurTypeSeekbar.apply {
417436
min = 0
418437
max = 4

app/src/main/res/layout/activity_main.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,40 @@
309309
android:textSize="16sp"
310310
android:textStyle="bold" />
311311

312+
<androidx.appcompat.widget.AppCompatTextView
313+
android:layout_width="match_parent"
314+
android:layout_height="wrap_content"
315+
android:layout_marginStart="20dp"
316+
android:layout_marginTop="10dp"
317+
android:layout_marginEnd="20dp"
318+
android:text="alpha"
319+
android:textColor="#000000"
320+
android:textSize="14sp"
321+
app:layout_constraintEnd_toEndOf="parent"
322+
app:layout_constraintStart_toStartOf="parent"
323+
app:layout_constraintTop_toBottomOf="@id/background" />
324+
325+
<SeekBar
326+
android:id="@+id/stroke_alpha_seekbar"
327+
android:layout_width="match_parent"
328+
android:layout_height="wrap_content"
329+
android:layout_marginStart="20dp"
330+
android:layout_marginTop="10dp"
331+
android:layout_marginEnd="20dp"
332+
app:layout_constraintEnd_toEndOf="parent"
333+
app:layout_constraintStart_toStartOf="parent"
334+
app:layout_constraintTop_toBottomOf="@id/x_title" />
335+
336+
<androidx.appcompat.widget.AppCompatTextView
337+
android:id="@+id/stroke_alpha_value"
338+
android:layout_width="match_parent"
339+
android:layout_height="wrap_content"
340+
android:layout_marginTop="10dp"
341+
android:text="100"
342+
android:textColor="#000000"
343+
android:textSize="14sp"
344+
android:gravity="center" />
345+
312346
<androidx.appcompat.widget.AppCompatTextView
313347
android:layout_width="match_parent"
314348
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)