From 0a84c3c1fb3eb295af041ce77bfa50985205e92c Mon Sep 17 00:00:00 2001 From: Ju YunGyeom <30407907+gemiJ@users.noreply.github.com> Date: Thu, 14 Apr 2022 03:05:21 +0900 Subject: [PATCH] =?UTF-8?q?[#22]=20RectangleButton,=20RoundButton=20Style?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moyeorun_android/views/RectangleButton.kt | 22 +++---------------- .../moyeorun_android/views/RoundButton.kt | 14 +++--------- ...tton.xml => selector_rectangle_button.xml} | 9 ++++++-- .../selector_rectangle_button_text.xml | 6 +++++ ...d_botton.xml => selector_round_button.xml} | 8 ++++++- .../drawable/selector_round_button_text.xml | 6 +++++ app/src/main/res/values/attrs.xml | 7 ------ app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/styles_views.xml | 20 +++++++++++++++++ 9 files changed, 54 insertions(+), 40 deletions(-) rename app/src/main/res/drawable/{shape_rectangle_button.xml => selector_rectangle_button.xml} (60%) create mode 100644 app/src/main/res/drawable/selector_rectangle_button_text.xml rename app/src/main/res/drawable/{shape_round_botton.xml => selector_round_button.xml} (61%) create mode 100644 app/src/main/res/drawable/selector_round_button_text.xml delete mode 100644 app/src/main/res/values/attrs.xml create mode 100644 app/src/main/res/values/styles_views.xml diff --git a/app/src/main/java/com/moyerun/moyeorun_android/views/RectangleButton.kt b/app/src/main/java/com/moyerun/moyeorun_android/views/RectangleButton.kt index 1b4bd06..11e9bd3 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/views/RectangleButton.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/views/RectangleButton.kt @@ -2,27 +2,11 @@ package com.moyerun.moyeorun_android.views import android.content.Context import android.util.AttributeSet -import androidx.appcompat.content.res.AppCompatResources.getDrawable +import android.view.ContextThemeWrapper import androidx.appcompat.widget.AppCompatButton -import androidx.core.content.ContextCompat import com.moyerun.moyeorun_android.R class RectangleButton constructor( context: Context, - attributeSet: AttributeSet -) : AppCompatButton(context, attributeSet) { - - init { - val typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.RectangleButton) - - val initialBackground = typedArray.getDrawable(R.styleable.RectangleButton_android_background) - this.background = initialBackground ?: getDrawable(context, R.drawable.shape_rectangle_button) - - val initialTextColor = typedArray.getColor(R.styleable.RectangleButton_android_textColor, ContextCompat.getColor(context, R.color.main_white)) - this.setTextColor(initialTextColor) - - this.textSize = 21F - - typedArray.recycle() - } -} \ No newline at end of file + attrs: AttributeSet? = null +) : AppCompatButton(ContextThemeWrapper(context, R.style.RectangleButtonTheme), attrs) \ No newline at end of file diff --git a/app/src/main/java/com/moyerun/moyeorun_android/views/RoundButton.kt b/app/src/main/java/com/moyerun/moyeorun_android/views/RoundButton.kt index 22d57e3..b3b75ce 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/views/RoundButton.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/views/RoundButton.kt @@ -2,19 +2,11 @@ package com.moyerun.moyeorun_android.views import android.content.Context import android.util.AttributeSet -import androidx.appcompat.content.res.AppCompatResources +import android.view.ContextThemeWrapper import androidx.appcompat.widget.AppCompatButton -import androidx.core.content.ContextCompat import com.moyerun.moyeorun_android.R class RoundButton constructor( context: Context, - attributeSet: AttributeSet -) : AppCompatButton(context, attributeSet) { - - init { - this.background = AppCompatResources.getDrawable(context, R.drawable.shape_round_botton) - this.setTextColor(ContextCompat.getColor(context, R.color.main_white)) - this.textSize = 18F - } -} \ No newline at end of file + attrs: AttributeSet? = null +) : AppCompatButton(ContextThemeWrapper(context, R.style.RoundButtonTheme), attrs) \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_rectangle_button.xml b/app/src/main/res/drawable/selector_rectangle_button.xml similarity index 60% rename from app/src/main/res/drawable/shape_rectangle_button.xml rename to app/src/main/res/drawable/selector_rectangle_button.xml index 2793da5..caea89d 100644 --- a/app/src/main/res/drawable/shape_rectangle_button.xml +++ b/app/src/main/res/drawable/selector_rectangle_button.xml @@ -1,10 +1,15 @@ - - + + + + + + + diff --git a/app/src/main/res/drawable/selector_rectangle_button_text.xml b/app/src/main/res/drawable/selector_rectangle_button_text.xml new file mode 100644 index 0000000..5ef8ee7 --- /dev/null +++ b/app/src/main/res/drawable/selector_rectangle_button_text.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_round_botton.xml b/app/src/main/res/drawable/selector_round_button.xml similarity index 61% rename from app/src/main/res/drawable/shape_round_botton.xml rename to app/src/main/res/drawable/selector_round_button.xml index 85637e9..a0c1b1a 100644 --- a/app/src/main/res/drawable/shape_round_botton.xml +++ b/app/src/main/res/drawable/selector_round_button.xml @@ -1,11 +1,17 @@ - + + + + + + + diff --git a/app/src/main/res/drawable/selector_round_button_text.xml b/app/src/main/res/drawable/selector_round_button_text.xml new file mode 100644 index 0000000..5ef8ee7 --- /dev/null +++ b/app/src/main/res/drawable/selector_round_button_text.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml deleted file mode 100644 index 3a5c190..0000000 --- a/app/src/main/res/values/attrs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index e374e51..f944f5b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -11,5 +11,7 @@ #EEF4FF + #0047D0 #C4C4C4 + #828282 \ No newline at end of file diff --git a/app/src/main/res/values/styles_views.xml b/app/src/main/res/values/styles_views.xml new file mode 100644 index 0000000..625864b --- /dev/null +++ b/app/src/main/res/values/styles_views.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file