pull/35/head^2
kunfei 5 years ago
parent ae7b937cd2
commit 8a05d8dde9
  1. 9
      app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt
  2. 1
      app/src/main/res/layout/item_rss.xml

@ -7,6 +7,7 @@ import android.graphics.Path
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import io.legado.app.R
import kotlin.math.max
class FilletImageView : AppCompatImageView {
internal var width: Float = 0.toFloat()
@ -62,11 +63,11 @@ class FilletImageView : AppCompatImageView {
override fun onDraw(canvas: Canvas) {
//这里做下判断,只有图片的宽高大于设置的圆角距离的时候才进行裁剪
val maxLeft = Math.max(leftTopRadius, leftBottomRadius)
val maxRight = Math.max(rightTopRadius, rightBottomRadius)
val maxLeft = max(leftTopRadius, leftBottomRadius)
val maxRight = max(rightTopRadius, rightBottomRadius)
val minWidth = maxLeft + maxRight
val maxTop = Math.max(leftTopRadius, rightTopRadius)
val maxBottom = Math.max(leftBottomRadius, rightBottomRadius)
val maxTop = max(leftTopRadius, rightTopRadius)
val maxBottom = max(leftBottomRadius, rightBottomRadius)
val minHeight = maxTop + maxBottom
if (width >= minWidth && height > minHeight) {
@SuppressLint("DrawAllocation") val path = Path()

@ -9,6 +9,7 @@
android:id="@+id/iv_icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@color/colorPrimary"
android:src="@drawable/ic_image"
android:scaleType="centerCrop"
app:layout_constraintTop_toTopOf="parent"

Loading…
Cancel
Save