{"id":10066,"date":"2019-09-20T17:17:38","date_gmt":"2019-09-20T08:17:38","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=10066"},"modified":"2019-09-20T17:17:40","modified_gmt":"2019-09-20T08:17:40","slug":"view%ec%97%90-%eb%91%a5%ea%b7%bc-%eb%aa%a8%ec%84%9c%eb%a6%ac%eb%a5%bc-%ea%b0%96%eb%8a%94-%eb%b0%b0%ea%b2%bd%ec%83%89-%ec%a7%80%ec%a0%95%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=10066","title":{"rendered":"View\uc5d0 \ub465\uadfc \ubaa8\uc11c\ub9ac\ub97c \uac16\ub294 \ubc30\uacbd\uc0c9 \uc9c0\uc815\ud558\uae30"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">\ub465\uadfc \ubaa8\uc11c\ub9ac\ub97c \uac16\ub294 \ub2e8\uc0c9 \ubc30\uacbd\uc744 \uc9c0\uc815\ud558\ub824\ub2e4 \ubcf4\uba74 \n\ub2e4\uc74c\uacfc \uac19\uc774 xml \uc744 \uc815\uc758\ud55c \ub4a4 View\uc758 \ubc30\uacbd\uc73c\ub85c \uc9c0\uc815\ud560 \uc218 \uc788\ub2e4.<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>(drawable\/bg_rounded.xml)\n\n&lt;shape android:shape=\"rectangle\">\n    &lt;solid android:color=\"@color\/bg_color\"\/>\n    &lt;corners android:radius=\"2dp\"\/>\n&lt;\/shape><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;LinearLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"@drawable\/bg_rounded\"><\/code><\/pre>\n\n\n\n<p>\ud558\uc9c0\ub9cc \ub2e4\ub978 \ubdf0\uc5d0\uc11c \uc0c9\uc0c1\uc774\ub098 radius \uac12\uc744 \ubcc0\uacbd\ud574\uc57c\ud558\ub294 \uacbd\uc6b0 \uc774 xml \uc744 \uc7ac\uc0ac\uc6a9\ud558\uae30\ub294 \uc27d\uc9c0 \uc54a\ub2e4. <\/p>\n\n\n\n<p>\uadf8\ub798\uc11c  Databinding\uc744 \ud65c\uc6a9\ud574\ubcf4\uae30\ub85c \ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ViewBindingAdapter {\n\n    @BindingAdapter(value = {\"bgCornerRadius\"})\n    public static void setBackgroundCornerRadius(View view, float cornerRadius){\n        if(view==null){\n            return;\n        }\n        Drawable drawable = view.getBackground();\n        cornerRadius *= view.getResources().getDisplayMetrics().density;\n        GradientDrawable gradientDrawable = GradientDrawableUtil.getGradientDrawable(drawable, cornerRadius);\n        view.setBackground(gradientDrawable);\n    }\n}\n\npublic class GradientDrawableUtil {\n\n    public static GradientDrawable getGradientDrawable(Drawable drawable, float cornerRadius){\n        GradientDrawable gradientDrawable;\n        if(drawable instanceof GradientDrawable){\n            gradientDrawable = (GradientDrawable) drawable;\n        }else{\n            gradientDrawable = new GradientDrawable();\n            if(drawable instanceof ColorDrawable){\n                ColorDrawable colorDrawable = (ColorDrawable) drawable;\n                gradientDrawable.setAlpha(colorDrawable.getAlpha());\n                gradientDrawable.setColor(colorDrawable.getColor());\n            }\n        }\n        gradientDrawable.setCornerRadius(cornerRadius);\n        return gradientDrawable;\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;LinearLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:bgCornerRadius=\"@{4f}\"\n    android:background=\"@color\/grey\"><\/code><\/pre>\n\n\n\n<p>xml\ub0b4\uc5d0\uc11c View \uc18d\uc131\uc5d0 \uac04\ub2e8\ud788 radius \uac12\uc744 \uc785\ub825\ud558\ub294\uac83\uc73c\ub85c \ub2e8\uc0c9\uc758 \ub465\uadfc \ubc30\uacbd\uc744 \ub9cc\ub4e4 \uc218 \uc788\ub2e4.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>\ub465\uadfc \ubaa8\uc11c\ub9ac\ub97c \uac16\ub294 \ub2e8\uc0c9 \ubc30\uacbd\uc744 \uc9c0\uc815\ud558\ub824\ub2e4 \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 xml \uc744 \uc815\uc758\ud55c \ub4a4 View\uc758 \ubc30\uacbd\uc73c\ub85c \uc9c0\uc815\ud560 \uc218 \uc788\ub2e4. \ud558\uc9c0\ub9cc \ub2e4\ub978 \ubdf0\uc5d0\uc11c \uc0c9\uc0c1\uc774\ub098 radius \uac12\uc744 \ubcc0\uacbd\ud574\uc57c\ud558\ub294 \uacbd\uc6b0 \uc774 xml \uc744 \uc7ac\uc0ac\uc6a9\ud558\uae30\ub294 \uc27d\uc9c0 \uc54a\ub2e4. \uadf8\ub798\uc11c Databinding\uc744 \ud65c\uc6a9\ud574\ubcf4\uae30\ub85c \ud55c\ub2e4. xml\ub0b4\uc5d0\uc11c View \uc18d\uc131\uc5d0 \uac04\ub2e8\ud788 radius \uac12\uc744 \uc785\ub825\ud558\ub294\uac83\uc73c\ub85c \ub2e8\uc0c9\uc758 \ub465\uadfc \ubc30\uacbd\uc744 \ub9cc\ub4e4 \uc218 \uc788\ub2e4.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[16],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/10066"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10066"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/10066\/revisions"}],"predecessor-version":[{"id":10067,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/10066\/revisions\/10067"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}