BadgeView支持绘制成上平角

pull/70/head
Administrator 5 years ago
parent 6515d53214
commit 899a362ea0
  1. 4
      app/src/main/java/io/legado/app/ui/widget/BadgeView.kt
  2. 1
      app/src/main/res/layout/item_bookshelf_grid.xml
  3. 1
      app/src/main/res/values/attrs.xml

@ -36,6 +36,7 @@ class BadgeView @JvmOverloads constructor(
text = text
}
private var radius: Float = 0.toFloat()
private var flatangle: Boolean
val badgeCount: Int?
get() {
@ -77,6 +78,8 @@ class BadgeView @JvmOverloads constructor(
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BadgeView)
val radios =
typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8)
flatangle =
typedArray.getBoolean(R.styleable.BadgeView_up_flat_angle, false)
typedArray.recycle()
if (layoutParams !is LayoutParams) {
@ -111,6 +114,7 @@ class BadgeView @JvmOverloads constructor(
val radius = dip2Px(dipRadius).toFloat()
val radiusArray =
floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius)
if (flatangle) { radiusArray.fill(0f, 0, 3) }
val roundRect = RoundRectShape(radiusArray, null, null)
val bgDrawable = ShapeDrawable(roundRect)

@ -56,6 +56,7 @@
android:includeFontPadding="false"
android:singleLine="true"
app:bv_radius="1dp"
app:up_flat_angle="true"
app:layout_constraintLeft_toLeftOf="@id/iv_cover"
app:layout_constraintBottom_toBottomOf="@id/iv_cover"
tools:ignore="RtlHardcoded" />

@ -143,5 +143,6 @@
<declare-styleable name="BadgeView">
<attr name="bv_radius" format="dimension" />
<attr name="up_flat_angle" format="boolean" />
</declare-styleable>
</resources>
Loading…
Cancel
Save