From 97b644db0f82faa84204de03225f9831bce0fbe5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 18 Mar 2020 18:08:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/widget/SearchView.kt | 36 +++++++++---------- app/src/main/res/layout/view_search.xml | 1 - 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt index a1d8bd5f6..13d2cbeaf 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt @@ -91,23 +91,23 @@ class SearchView : SearchView { super.setQueryHint(hint) updateQueryHint() } -} -internal class CenteredImageSpan(drawable: Drawable?) : ImageSpan(drawable!!) { - override fun draw( - canvas: Canvas, text: CharSequence, - start: Int, end: Int, x: Float, - top: Int, y: Int, bottom: Int, paint: Paint - ) { - // image to draw - val b = drawable - // font metrics of text to be replaced - val fm = paint.fontMetricsInt - val transY = ((y + fm.descent + y + fm.ascent) / 2 - - b.bounds.bottom / 2) - canvas.save() - canvas.translate(x, transY.toFloat()) - b.draw(canvas) - canvas.restore() + internal class CenteredImageSpan(drawable: Drawable?) : ImageSpan(drawable!!) { + override fun draw( + canvas: Canvas, text: CharSequence, + start: Int, end: Int, x: Float, + top: Int, y: Int, bottom: Int, paint: Paint + ) { + // image to draw + val b = drawable + // font metrics of text to be replaced + val fm = paint.fontMetricsInt + val transY = ((y + fm.descent + y + fm.ascent) / 2 + - b.bounds.bottom / 2) + canvas.save() + canvas.translate(x, transY.toFloat()) + b.draw(canvas) + canvas.restore() + } } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/view_search.xml b/app/src/main/res/layout/view_search.xml index b1809c534..96ff311da 100644 --- a/app/src/main/res/layout/view_search.xml +++ b/app/src/main/res/layout/view_search.xml @@ -14,5 +14,4 @@ app:queryBackground="@null" app:submitBackground="@null" app:searchHintIcon="@drawable/ic_search_hint" - app:goIcon="@drawable/ic_search" app:defaultQueryHint="搜索"/> \ No newline at end of file