From a34697b5404da7415cd9a448dd0421ca6dc04824 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 4 Feb 2020 09:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/widget/image/CoverImageView.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 2f7bfb74e..a494f9ca9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -35,6 +35,8 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { init { textPaint.typeface = Typeface.DEFAULT_BOLD textPaint.isAntiAlias = true + textPaint.textAlign = Paint.Align.CENTER + textPaint.textSkewX = -0.2f } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { @@ -50,7 +52,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { super.onLayout(changed, left, top, right, bottom) width = getWidth().toFloat() height = getHeight().toFloat() - textPaint.textSize = width / 8 + textPaint.textSize = width / 6 textPaint.strokeWidth = textPaint.textSize / 10 } @@ -75,15 +77,20 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { name?.let { textPaint.color = Color.WHITE textPaint.style = Paint.Style.STROKE - canvas.drawText(it, width / 6, height * 2 / 3, textPaint) + canvas.drawText(it, width / 2, height * 3 / 5, textPaint) textPaint.color = Color.BLACK textPaint.style = Paint.Style.FILL - canvas.drawText(it, width / 6, height * 2 / 3, textPaint) + canvas.drawText(it, width / 2, height * 3 / 5, textPaint) } } fun setName(name: String?, author: String?) { - this.name = name + this.name = + when { + name == null -> null + name.length > 5 -> name.substring(0, 4) + "…" + else -> name + } this.author = author invalidate() }