{"id":444,"date":"2024-02-04T15:10:05","date_gmt":"2024-02-04T15:10:05","guid":{"rendered":"https:\/\/www.hadooh.com\/?p=444"},"modified":"2024-02-08T11:01:24","modified_gmt":"2024-02-08T11:01:24","slug":"%eb%b2%84%ed%8a%bc-color%ec%a0%95%eb%b3%b4-%ea%b0%80%ec%a0%b8%ec%98%a4%eb%8a%94-%eb%b0%a9%eb%b2%95","status":"publish","type":"post","link":"https:\/\/www.hadooh.com\/?p=444","title":{"rendered":"\uc548\ub4dc\ub85c\uc774\ub4dc \ubc84\ud2bc background color\uc815\ubcf4 \uac00\uc838\uc624\ub294 \ubc29\ubc95"},"content":{"rendered":"\n<p>\uc548\ub4dc\ub85c\uc774\ub4dc \ubc84\ud2bc \uc815\ubcf4 \uc911\uc5d0  background\ub97c \uceec\ub7ec\ub97c \uc14b\ud305(setBackgroundColor)\ud558\ub294\uac74 \uc815\ub9d0 \uc26c\uc6b4\ub370,<br>\ubc84\ud2bc\uc758 backgroudcolor\ub97c \uac00\uc838\uc624\ub294\uac8c \ub108\ubb34 \ud798\ub4e4\uc5c8\ub2e4.<\/p>\n\n\n\n<p>\uad6c\uae00\uac80\uc0c9, stackoverflow\uac80\uc0c9 \ub4f1\ub4f1 \uc5ec\ub7ec\uac00\uc9c0\ub97c \uc2dc\ub3c4\ud574\ubcf4\ub2e4\uac00 \uaca8\uc6b0 \ubc29\ubc95\uc744 \ucc3e\uc544\uc11c \ub0b4\uc6a9\uc744 \ub0a8\uaca8\ub454\ub2e4. <\/p>\n\n\n\n<p>\ucc3e\uae30 \ud798\ub4e4\uc5c8\ub358 \uc774\uc720 \uc911\uc5d0 \ub300\ubd80\ubd84\uc740 \uc548\ub4dc\ub85c\uc774\ub4dc\uac00 java\uc5d0\uc11c kotlin\uc73c\ub85c \ubc14\ub00c\uace0, \uc911\uac04\uc911\uac04\uc5d0 \uc548\ub4dc\ub85c\uc774\ub4dc\uac00 \uc5c5\ub370\uc774\ud2b8\ub418\uba74\uc11c \uae30\uc874\uc5d0 \uc798 \uc0ac\uc6a9\ud558\ub358 \ubc29\ubc95\uc774 \ub354\uc774\uc0c1 \uc548\ub418\ub294 \uac83\ub54c\ubb38\uc5d0 \ubc29\ubc95\uc744 \ucc3e\ub294\uac8c \ub108\ubb34 \ud798\ub4e4\uc5c8\ub2e4.<\/p>\n\n\n\n<p>\uac80\uc0c9\ud558\uba74 \ub098\uc624\ub294 \uac00\uc7a5 \ud070 \uc194\ub8e8\uc158 \uc911\uc5d0 themes.xml\uc5d0 style parent\uc18d\uc131\uc774 Theme.AppCompat.Light \ub85c \ubc14\ub00c\ub294\uac74 \uc774\ubbf8 \ub418\uc5b4 \uc788\uc5c8\uae30 \ub54c\ubb38\uc5d0 \uc815\ub2f5\uc774 \uc544\ub2c8\uc5c8\ub2e4.<\/p>\n\n\n\n<p>\ub450\ubc88\uc9f8\ub85c \ub808\uc774\uc544\uc6c3.xml\uc5d0\uc11c android.widget.Button\ub85c \ubcc0\uacbd\ud558\ub294\uac74, \ubcc0\uacbd\uc744 \ud574\ub3c4 \ub3d9\uc77c\ud55c \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\ub2e4.<\/p>\n\n\n\n<p>\ub0b4\uac00 \ucc3e\uc740 \ubc29\ubc95\uc740 \ubc84\ud2bc background\uc815\ubcf4\ub97c Drawable \ud074\ub798\uc2a4\ub85c \ubc1b\uc544\uc11c, \uac01 \ud074\ub798\uc2a4(ColorDrawable,StateListDrawable,GradientDrawable,ColorDrawable)\uc5d0 \ub9de\uac8c color\uc815\ubcf4\ub97c \uac00\uc838\uc640\uc11c \uc0ac\uc6a9\ud558\ub3c4\ub85d \ud588\ub2e4.<br>\ucc98\uc74c\uc5d0\ub294 \uc5b4\ub290 Drawable\ud074\ub798\uc2a4\ub85c \ubc1b\uc544\uc57c \ub420\uc9c0 \ubab0\ub77c\uc11c \uc0bd\uc9c8\uc744 \uacc4\uc18d \ud588\ub294\ub370, \uacb0\uad6d \uc544\ub798\uc640 \uac19\uc740 \ucc98\ub9ac\ubc29\ubc95\uc744 \ucc3e\uc544\uc11c \uc0ac\uc6a9\ud588\ub354\ub2c8 \ubc84\ud2bc\uc758 backgroundcolor\uc815\ubcf4\ub97c \uc811\uadfc\ud560 \uc218 \uc788\uc5c8\ub2e4.<br>color\uc815\ubcf4\ub97c \uac00\uc838\uc624\uba74 \uae30\ubcf8\uc774 int\ud615 \ubcc0\uc218\uc778\ub370, \uc774\uac78 \ud615\ubcc0\ud658\ud558\uba74 rgb string\uac12\uc73c\ub85c \uac00\uc838\uc62c \uc218 \uc788\ub2e4.(\ud615\ubcc0\ud658\ucc38\uace0: <strong>val hexColor = String.format(&#8220;#%06X&#8221;, color2)<\/strong>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Kotlin\uc18c\uc2a4\ucf54\ub4dc\n<strong>private fun startAnimation(bt: android.widget.Button) : Unit {\n        val drawable : Drawable = bt.background\n        var rtnColor = 0    \/\/ \uae30\uc874\ubc84\ud2bc\uc758 \uc0c9\uc744 \ub2f4\uc744 \ubcc0\uc218\n        when (drawable) {\n            is ColorDrawable -&gt; {\n                val color = drawable.color\n                Log.d(tagName, \"startBingoAnimation ColorDrawable color:$color\")\n                rtnColor = color\n            }\n            is StateListDrawable -&gt; {\n                val drawable2 = drawable?.getStateDrawable(0) \/\/as StateListDrawable\n                when (drawable2) {\n                    is ShapeDrawable -&gt; {\n                        val color = drawable2.paint.color\n                        Log.d(tagName, \"startBingoAnimation ShapeDrawable color:$color\")\n                        rtnColor = color\n                    }\n\n                    is GradientDrawable -&gt; {\n                        val color: ColorStateList? = drawable2.color\n                        val color2: Int = color!!.defaultColor\n                        Log.d(tagName, \"startBingoAnimation GradientDrawable color:${color2}\")\n                        \/\/val colorStr = color2?.toString(16)\n                        val hexColor = String.format(\"#%06X\", color2)\n                        \/\/Log.d(tagName, \"startBingoAnimation GradientDrawable hexColor:${hexColor}\")\n                        Log.d(tagName, \"startBingoAnimation GradientDrawable color:${color2} to hexColor:${hexColor}\")\n                        rtnColor = color2\n                    }\n\n                    is ColorDrawable -&gt; {\n                        val color = drawable2.color\n                        Log.d(tagName, \"startBingoAnimation ColorDrawable color:$color\")\n                        rtnColor = color\n                    }\n\n                    else -&gt; {\n                        Log.d(tagName, \"startBingoAnimation Drawable else\")\n                    }\n                }\n            }\n        }\n\n        val startColor = Color.parseColor(\"#FFCC33\")\n        val endColor = if(rtnColor==0) Color.parseColor(\"#FF9933\") else rtnColor\n\n\n        val animator = ValueAnimator.ofArgb(startColor, endColor)\n        animator.duration = 1000\n        animator.addUpdateListener { valueAnimator -&gt;\n            val animatedValue = valueAnimator.animatedValue as Int\n            bt.setBackgroundColor(animatedValue)\n        }\n        animator.start()<\/strong><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc548\ub4dc\ub85c\uc774\ub4dc \ubc84\ud2bc \uc815\ubcf4 \uc911\uc5d0 background\ub97c \uceec\ub7ec\ub97c \uc14b\ud305(setBackgroundColor)\ud558\ub294\uac74 \uc815\ub9d0 \uc26c\uc6b4\ub370,\ubc84\ud2bc\uc758 backgroudcolor\ub97c \uac00\uc838\uc624\ub294\uac8c \ub108\ubb34 \ud798\ub4e4\uc5c8\ub2e4. \uad6c\uae00\uac80\uc0c9, stackoverflow\uac80\uc0c9 \ub4f1\ub4f1 \uc5ec\ub7ec\uac00\uc9c0\ub97c \uc2dc\ub3c4\ud574\ubcf4\ub2e4\uac00 \uaca8\uc6b0 \ubc29\ubc95\uc744 \ucc3e\uc544\uc11c \ub0b4\uc6a9\uc744 \ub0a8\uaca8\ub454\ub2e4. \ucc3e\uae30 \ud798\ub4e4\uc5c8\ub358 \uc774\uc720 \uc911\uc5d0 \ub300\ubd80\ubd84\uc740 \uc548\ub4dc\ub85c\uc774\ub4dc\uac00 java\uc5d0\uc11c kotlin\uc73c\ub85c \ubc14\ub00c\uace0, \uc911\uac04\uc911\uac04\uc5d0 \uc548\ub4dc\ub85c\uc774\ub4dc\uac00 \uc5c5\ub370\uc774\ud2b8\ub418\uba74\uc11c \uae30\uc874\uc5d0 \uc798 \uc0ac\uc6a9\ud558\ub358 \ubc29\ubc95\uc774 \ub354\uc774\uc0c1 \uc548\ub418\ub294 \uac83\ub54c\ubb38\uc5d0 \ubc29\ubc95\uc744 \ucc3e\ub294\uac8c \ub108\ubb34 \ud798\ub4e4\uc5c8\ub2e4. \uac80\uc0c9\ud558\uba74 \ub098\uc624\ub294 \uac00\uc7a5 \ud070 \uc194\ub8e8\uc158 \uc911\uc5d0 themes.xml\uc5d0 style parent\uc18d\uc131\uc774 &hellip; <a href=\"https:\/\/www.hadooh.com\/?p=444\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\uc548\ub4dc\ub85c\uc774\ub4dc \ubc84\ud2bc background color\uc815\ubcf4 \uac00\uc838\uc624\ub294 \ubc29\ubc95<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/posts\/444"}],"collection":[{"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=444"}],"version-history":[{"count":4,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/posts\/444\/revisions"}],"predecessor-version":[{"id":449,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=\/wp\/v2\/posts\/444\/revisions\/449"}],"wp:attachment":[{"href":"https:\/\/www.hadooh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hadooh.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}