From 5cfce754356796f75957e76d658d1ed558c6b266 Mon Sep 17 00:00:00 2001 From: HayleyKim0716 Date: Thu, 4 Aug 2022 00:26:49 +0900 Subject: [PATCH] =?UTF-8?q?#6=20feat/=ED=99=88=20:=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=88=98=EC=A0=95=20-?= =?UTF-8?q?=20TextView=20=EC=9D=98=20drawableStart=20=EC=86=8D=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0,=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=EC=A6=88=20=EB=B3=80=EA=B2=BD=EC=9D=B4=20=EC=96=B4=EB=A0=A4?= =?UTF-8?q?=EC=9B=8C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=B7=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ftw/hometerview/design/Button.kt | 8 +++---- design/src/main/res/layout/view_button.xml | 23 +++++++++++++++---- design/src/main/res/values/dimens.xml | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/design/src/main/java/com/ftw/hometerview/design/Button.kt b/design/src/main/java/com/ftw/hometerview/design/Button.kt index 36a4f95..b4257a5 100644 --- a/design/src/main/java/com/ftw/hometerview/design/Button.kt +++ b/design/src/main/java/com/ftw/hometerview/design/Button.kt @@ -3,6 +3,7 @@ package com.ftw.hometerview.design import android.content.Context import android.graphics.drawable.Drawable import android.util.AttributeSet +import android.widget.ImageView import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.children @@ -16,15 +17,14 @@ class Button @JvmOverloads constructor( attributeSet: AttributeSet? = null, defStyle: Int = 0 ) : ConstraintLayout(context, attributeSet, defStyle) { + private val drawableStartImageView: ImageView private val titleTextView: TextView private val numberTextView: TextView var icon: Drawable? = null set(value) { field = value - titleTextView.setCompoundDrawablesWithIntrinsicBounds(value, null, null, null) - titleTextView.compoundDrawablePadding = - resources.getDimensionPixelSize(R.dimen.button_drawable_padding) + drawableStartImageView.setImageDrawable(value) } var text: String? = null @@ -46,6 +46,7 @@ class Button @JvmOverloads constructor( init { inflate(context, R.layout.view_button, this) + drawableStartImageView = findViewById(R.id.drawable_start_image_view) titleTextView = findViewById(R.id.title_text_view) numberTextView = findViewById(R.id.number_text_view) @@ -81,5 +82,4 @@ class Button @JvmOverloads constructor( super.setEnabled(enabled) children.forEach { it.isEnabled = enabled } } - } diff --git a/design/src/main/res/layout/view_button.xml b/design/src/main/res/layout/view_button.xml index 2282052..f2ed8a4 100644 --- a/design/src/main/res/layout/view_button.xml +++ b/design/src/main/res/layout/view_button.xml @@ -2,20 +2,34 @@ + + diff --git a/design/src/main/res/values/dimens.xml b/design/src/main/res/values/dimens.xml index 509cd09..10552d1 100644 --- a/design/src/main/res/values/dimens.xml +++ b/design/src/main/res/values/dimens.xml @@ -3,6 +3,8 @@ 12dp 27dp + 14dp + 4dp 1dp 4dp 8dp