{"id":1390,"date":"2022-05-06T23:32:40","date_gmt":"2022-05-06T14:32:40","guid":{"rendered":"http:\/\/batmask.dothome.co.kr\/?p=1390"},"modified":"2025-09-12T17:21:22","modified_gmt":"2025-09-12T08:21:22","slug":"android-screen-rotation-%ec%95%8c%ec%95%84%eb%82%b4%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/batmask.net\/index.php\/2022\/05\/06\/1390\/","title":{"rendered":"Android: Screen Rotation \uc54c\uc544\ub0b4\uae30"},"content":{"rendered":"\n<p>\ubcf4\ud1b5 \ud654\uba74\uc758 \ud68c\uc804\uc744 \ucc98\ub9ac\ud558\ub294 \uacbd\uc6b0\ub294 \ud654\uba74\uc774 portrait\uc778\uc9c0 landscape\uc778\uc9c0 \uc5ec\ubd80\uc774\ub2e4. \uadf8\ub7ec\ub098, \ub098\uce68\ubc18\ucc98\ub7fc \ud68c\uc804\ubc29\ud5a5\uc5d0 \ub530\ub77c \ubc14\ub298 \uac01\ub3c4\ub97c \ub2e4\ub974\uac8c \uacc4\uc0b0\ud574\uc57c \ud558\ub294 \uacbd\uc6b0\ub77c\uba74, 4\ubc29\ud5a5\uc758 \ud68c\uc804\ubc29\ud5a5\uc744 \ubaa8\ub450 \uc54c\uc544\uc57c\ud55c\ub2e4. \uc5ec\uae30\uc11c\ub294 \ub2e4\ub8e8\uc9c0 \uc54a\uc9c0\ub9cc \uc0ac\uc871\uc744 \ub2ec\uc790\uba74, \ub098\uce68\ubc18\uc740 \ud654\uba74\uc774 \ub4a4\uc9d1\ud600 \uc88c\ud45c\uacc4\uac00 \ub4a4\uc9d1\ud788\ub294 \uacbd\uc6b0\uae4c\uc9c0 \uace0\ub824\ud574\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud654\uba74\uc758 \ud604\uc7ac \ud68c\uc804\uc0c1\ud0dc\ub97c \uc54c\uc544\ub0b4\ub294 \ubc29\ubc95<\/h3>\n\n\n\n<p> \ud654\uba74\uc758 \ud68c\uc804\uc740 UI\uc601\uc5ed\uc774\uace0, Activity\uc5d0\uc11c \ucc98\ub9ac\ud574\uc57c \ud568\uc744 \uc720\ucd94\ud560 \uc218 \uc788\ub2e4. Fragment\uac00 \uc544\ub2c8\ub77c Activity\uc778 \uc774\uc720\ub294, Fragment\uac00 \uac1c\ubcc4\uc801\uc73c\ub85c rotation\uc774 \ub418\uc9c0 \uc54a\uae30 \ub54c\ubb38\uc774\ub2e4. \uc21c\uac04 \ub354\ube14\uc2a4\ud06c\ub9b0\uc5d0 \ud558\ub098\ub9cc \uac00\ub85c\ubaa8\ub4dc\ub85c \ub3cc\uc544\uac00\ub294 \uc608\uc804 LG \uc719\uc2a4\uac00 \uc0dd\uac01\ub098\uc9c0\ub9cc \u314b\u314b\u314b \uc544\ub9c8 \ubcc4\ub3c4\uc758 Activity\ub85c \ucc98\ub9ac\ud588\uaca0\uc9c0. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Portrait \/ Landscape<\/h4>\n\n\n\n<p> \uba3c\uc800, \ud604\uc7ac \uc0c1\ud0dc\ub97c \uc54c\uc544\ub0b4\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uc790. portrait\/landscape \uc5ec\ubd80\ub294 Activity\uc5d0\uc11c \ub2e4\uc74c\uc744 \uc774\uc6a9\ud574\uc11c \uccb4\ud06c \uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>when(resources.configuration.orientation) {\n    Configuration.ORIENTATION_PORTRAIT -> {}\n    Configuration.ORIENTATION_LANDSCAPE -> {}\n    else -> {} \/\/ Configuration.ORIENTATION_UNDEFINED \n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">when<\/span><span style=\"color: #ADBAC7\">(resources.configuration.orientation) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    Configuration.ORIENTATION_PORTRAIT <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> {}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    Configuration.ORIENTATION_LANDSCAPE <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> {}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">else<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> {} <\/span><span style=\"color: #768390\">\/\/ Configuration.ORIENTATION_UNDEFINED <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Activity\ub9d0\uace0 application\uc758 context\ub97c \uc774\uc6a9\ud558\uba74 \uc548\ub420\uae4c \uc0dd\uac01\ud560 \uc218 \uc788\ub294\ub370, getResources()\uac00 Android R(11) \ubd80\ud130 \uba40\ud2f0\uc708\ub3c4\uc6b0\ub098 \uc138\ucee8\ub4dc \uc708\ub3c4\uc6b0\uc758 \uac12\uc774 \uc904\uc218\ub3c4 \uc788\uc5b4 Activity(\uc815\ud655\ud788\ub294 WindowContext)\ub97c \uc774\uc6a9\ud574\uc57c \ud55c\ub2e4\uace0 \ub098\uc628\ub2e4. <a href=\"https:\/\/developer.android.com\/reference\/android\/content\/res\/Resources\">\ud574\ub2f9 \uac00\uc774\ub4dc\ubb38\uc11c<\/a>\ub97c \uc778\uc6a9\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 \ub418\uc5b4\uc788\ub2e4.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>After\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/os\/Build.VERSION_CODES#R\">Build.VERSION_CODES#R<\/a><\/code>,\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/res\/Resources\">Resources<\/a><\/code>\u00a0must be obtained by\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Activity\">Activity<\/a><\/code>\u00a0or\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Context\">Context<\/a><\/code>\u00a0created with\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Context#createWindowContext(int,%20android.os.Bundle)\">Context.createWindowContext(int, Bundle)<\/a><\/code>.\u00a0<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/ContextWrapper#getResources()\">Application#getResources()<\/a><\/code>\u00a0may report wrong values in multi-window or on secondary displays.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\">Rotation 0, 90, 180, 270 degree<\/h4>\n\n\n\n<p>\ud654\uba74\uc758 4\ubc29\ud5a5 \ud68c\uc804\uc744 \uc54c\uc544\ub0b4\ub824\uba74, DisplayManager\ub97c \uc774\uc6a9\ud558\uba70 \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>val display = getSystemService&lt;DisplayManager>()?.getDisplay(Display.DEFAULT_DISPLAY)\nif (display != null) {\n    when(display.rotation) {\n        Surface.ROTATION_0 -> { }\n        Surface.ROTATION_90 -> { }\n        Surface.ROTATION_180 -> { }\n        Surface.ROTATION_270 -> { }\n    }\n\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">val<\/span><span style=\"color: #ADBAC7\"> display <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #DCBDFB\">getSystemService<\/span><span style=\"color: #ADBAC7\">&lt;<\/span><span style=\"color: #F69D50\">DisplayManager<\/span><span style=\"color: #ADBAC7\">&gt;()?.<\/span><span style=\"color: #DCBDFB\">getDisplay<\/span><span style=\"color: #ADBAC7\">(Display.DEFAULT_DISPLAY)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F47067\">if<\/span><span style=\"color: #ADBAC7\"> (display <\/span><span style=\"color: #F47067\">!=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">null<\/span><span style=\"color: #ADBAC7\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">when<\/span><span style=\"color: #ADBAC7\">(display.rotation) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_0 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_90 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_180 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_270 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Window\uac00 \uc544\ub2c8\uace0 Display\ub85c\ubd80\ud130 \uc5bb\uc5b4\uc624\ub294 \uac83\uc778\ub370, Display.DEFAULT_DISPLAY\ub97c \uc0ac\uc6a9\ud558\uace0 \uc788\ub2e4. \ub9cc\uc57d\uc5d0 \ub2e4\uc911 \ub514\uc2a4\ud50c\ub808\uc774\uac00 \uc874\uc7ac\ud55c\ub2e4\uba74 \uc774\ubd80\ubd84\uc744 \uace0\ub824\ud574\uc57c \ud558\uaca0\uc9c0\ub9cc, \ubcf4\ud1b5\uc740 \uc774\uac78\ub85c \ucda9\ubd84\ud558\uaca0\uc9c0. \uc774\uc81c, \ub3d9\uc801\uc73c\ub85c \ubcc0\uacbd\ub418\ub294 \uc2dc\uc810\uc744 \uc7a1\uc544\ub0b4\uc11c \ud544\uc694\ud55c \ucc98\ub9ac\ub97c \ud574\ubcf4\uc790.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud654\uba74\uc774 \ub3d9\uc801\uc73c\ub85c \ub3cc\uc544\uac00\ub294 \uacbd\uc6b0, \ubcc0\uacbd \uc2dc\uc810\uc744 \uc54c\uc544\ub0b4\uace0 \ucc98\ub9ac\ud558\uae30<\/h3>\n\n\n\n<p> \ud654\uba74\uc758 \ud68c\uc804 \ubc0f \uc5ec\ub7ec configuration \uc0ac\ud56d\uc758 \ubcc0\uacbd\uc740 Activity\uc758 onConfigurationChanged()\uac00 \ud638\ucd9c\ub41c\ub2e4. \uc790\uc138\ud55c \ub0b4\uc6a9\uc740 <a href=\"https:\/\/developer.android.com\/guide\/topics\/resources\/runtime-changes\">\uacf5\uc2dd \uac00\uc774\ub4dc\ubb38\uc11c<\/a>\ub97c \ucc38\uc870\ud558\uae30 \ubc14\ub780\ub2e4. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">AndroidManifest.xml \uc218\uc815<\/h4>\n\n\n\n<p>\uadf8\ub7fc Activity\uc5d0 \ud574\ub2f9 \ucf5c\ubc31 \ud558\ub098\ub9cc \ucd94\uac00\ud558\uba74 \ub418\ub294\uac78\uae4c? \uc544\ub2c8\uc544\ub2c8. \uadf8\ub0e5\uc740 \ubd88\ub9ac\uc9c0 \uc54a\ub294\ub2e4. \uc6b0\uc120, AndroidManifest.xml\uc758 \ud574\ub2f9 Activity\uc5d0 \ub2e4\uc74c\uacfc \uac19\uc774 \uc5b8\uc81c onConfigurationChanged()\ucf5c\ubc31\uc774 \ubd88\ub9b4\uc9c0 \uba85\uc2dc\ud574\uc918\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;activity\n\n    ...\n    android:configChanges=\"orientation|screenSize|screenLayout\"\n><\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #ADBAC7\">&lt;<\/span><span style=\"color: #8DDB8C\">activity<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    ...<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #6CB6FF\">android:configChanges<\/span><span style=\"color: #ADBAC7\">=<\/span><span style=\"color: #96D0FF\">&quot;orientation|screenSize|screenLayout&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>configChanges \ud56d\ubaa9\uc740 <a href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#config\">\uacf5\uc2dd \uac00\uc774\ub4dc\ubb38\uc11c\ub97c \ucc38\uace0<\/a>\ud558\uc790. \ubb38\uc11c \ub0b4\uc6a9\uc744 \uc778\uc6a9\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc740 \ud56d\ubaa9\ub4e4\uc774 \uc870\ud569\ub420 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><th>Value<\/th><th>Description<\/th><\/tr><tr><td>&#8220;<code>density<\/code>&#8220;<\/td><td>The display density has changed \u2014 the user might have specified a different display scale, or a different display might now be active.<em>Added in API level 24<\/em>.<\/td><\/tr><tr><td>&#8220;<code>fontScale<\/code>&#8220;<\/td><td>The font scaling factor has changed \u2014 the user has selected a new global font size.<\/td><\/tr><tr><td>&#8220;<code>keyboard<\/code>&#8220;<\/td><td>The keyboard type has changed \u2014 for example, the user has plugged in an external keyboard.<\/td><\/tr><tr><td>&#8220;<code>keyboardHidden<\/code>&#8220;<\/td><td>The keyboard accessibility has changed \u2014 for example, the user has revealed the hardware keyboard.<\/td><\/tr><tr><td>&#8220;<code>layoutDirection<\/code>&#8220;<\/td><td>The layout direction has changed \u2014 for example, changing from left-to-right (LTR) to right-to-left (RTL).<em>Added in API level 17<\/em>.<\/td><\/tr><tr><td>&#8220;<code>locale<\/code>&#8220;<\/td><td>The locale has changed \u2014 the user has selected a new language that text should be displayed in.<\/td><\/tr><tr><td>&#8220;<code>mcc<\/code>&#8220;<\/td><td>The IMSI mobile country code (MCC) has changed \u2014 a SIM has been detected and updated the MCC.<\/td><\/tr><tr><td>&#8220;<code>mnc<\/code>&#8220;<\/td><td>The IMSI mobile network code (MNC) has changed \u2014 a SIM has been detected and updated the MNC.<\/td><\/tr><tr><td>&#8220;<code>navigation<\/code>&#8220;<\/td><td>The navigation type (trackball\/dpad) has changed. (This should never normally happen.)<\/td><\/tr><tr><td><strong><span class=\"has-inline-color has-vivid-red-color\">&#8220;<code>orientation<\/code>&#8220;<\/span><\/strong><\/td><td><span class=\"has-inline-color has-vivid-red-color\">The screen orientation has changed \u2014 the user has rotated the device.<strong>Note:<\/strong>&nbsp;If your application targets Android 3.2 (API level 13) or higher, then you should also declare the&nbsp;<code>\"screenSize\"<\/code>&nbsp;and&nbsp;<code>\"screenLayout\"<\/code>&nbsp;configurations, because they might also change when a device switches between portrait and landscape orientations.<\/span><\/td><\/tr><tr><td>&#8220;<code>screenLayout<\/code>&#8220;<\/td><td>The screen layout has changed \u2014 a different display might now be active.<\/td><\/tr><tr><td>&#8220;<code>screenSize<\/code>&#8220;<\/td><td>The current available screen size has changed.This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait.<em>Added in API level 13<\/em>.<\/td><\/tr><tr><td>&#8220;<code>smallestScreenSize<\/code>&#8220;<\/td><td>The physical screen size has changed.This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the&nbsp;<a href=\"https:\/\/developer.android.com\/guide\/topics\/resources\/providing-resources#SmallestScreenWidthQualifier\">smallestWidth configuration<\/a>.<em>Added in API level 13<\/em>.<\/td><\/tr><tr><td>&#8220;<code>touchscreen<\/code>&#8220;<\/td><td>The touchscreen has changed. (This should never normally happen.)<\/td><\/tr><tr><td>&#8220;<code>uiMode<\/code>&#8220;<\/td><td>The user interface mode has changed \u2014 the user has placed the device into a desk or car dock, or the night mode has changed. For more information about the different UI modes, see&nbsp;<code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/UiModeManager\">UiModeManager<\/a><\/code>.<em>Added in API level 8<\/em>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\ud45c\uc5d0\uc11c \ube68\uac04\uc0c9 \uae00\uc790\ub85c \ud45c\uc2dc\ud574\ub1a8\ub294\ub370, orientation\uc744 \uc6b0\uc120 \uc0ac\uc6a9\ud574\uc57c\ud55c\ub2e4. \uadf8\ub9ac\uace0 \uc124\uba85\uc744 \ubcf4\uba74, Android 3.2(API 13)\uc774\uc0c1\uc774\uba74 screenSize\uc640 screenLayout\ub3c4 \ub3d9\uc2dc\uc5d0 \uc0ac\uc6a9\ud574\uc57c \ub41c\ub2e4\uace0 \ub098\uc628\ub2e4. \uc2e4\uc81c\ub85c orientation\ub9cc \uc0ac\uc6a9\ud558\uba74 \ucf5c\ubc31\uc774 \ud638\ucd9c\ub418\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">onConfigurationChanged() \uad6c\ud604<\/h4>\n\n\n\n<p> \uc790, \uc774\uc81c onConfigurationChanged()\ub294 \ubd88\ub9b0\ub2e4. \uc774 \ucf5c\ubc31\uc548\uc5d0\uc11c \ud544\uc694\ud55c \ucc98\ub9ac\ub97c \ud558\uc790. portrait\/landscape\uc758 \uacbd\uc6b0\uc5d0\ub294 \uad73\uc774 Activity.getResources()\ub97c \uc0ac\uc6a9\ud560 \ud544\uc694\uac00 \uc5c6\ub2e4. \uc778\uc790\ub85c \ub118\uc5b4\uc624\ub294 Configuration\uc5d0 \uc815\ubcf4\uac00 \ub4e4\uc5b4\uc788\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>override fun onConfigurationChanged(newConfig: Configuration) {\n    super.onConfigurationChanged(newConfig)\n\n    \/\/ Checks the orientation of the screen\n    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {\n    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">override<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">fun<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #DCBDFB\">onConfigurationChanged<\/span><span style=\"color: #ADBAC7\">(newConfig: <\/span><span style=\"color: #F69D50\">Configuration<\/span><span style=\"color: #ADBAC7\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #6CB6FF\">super<\/span><span style=\"color: #ADBAC7\">.<\/span><span style=\"color: #DCBDFB\">onConfigurationChanged<\/span><span style=\"color: #ADBAC7\">(newConfig)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #768390\">\/\/ Checks the orientation of the screen<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">if<\/span><span style=\"color: #ADBAC7\"> (newConfig.orientation <\/span><span style=\"color: #F47067\">==<\/span><span style=\"color: #ADBAC7\"> Configuration.ORIENTATION_LANDSCAPE) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    } <\/span><span style=\"color: #F47067\">else<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">if<\/span><span style=\"color: #ADBAC7\"> (newConfig.orientation <\/span><span style=\"color: #F47067\">==<\/span><span style=\"color: #ADBAC7\"> Configuration.ORIENTATION_PORTRAIT) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\uadf8\ub7fc, 4\ubc29\ud5a5 \ud68c\uc804\uc0c1\ud0dc\ub294 \uc5b4\ub5bb\uac8c\ub420\uae4c? \uc544\uc27d\uac8c\ub3c4 Configuration\uc5d0 \ud574\ub2f9 \uc815\ubcf4\ub294 \uc5c6\ub2e4. \uc55e\uc5d0\uc11c\uc640 \ub3d9\uc77c\ud558\uac8c, DisplayManager\ub97c \uc774\uc6a9\ud55c\ub2e4. \uc5b4\uca0c\ub4e0 \uc5b4\ub290\ucabd\uc73c\ub85c\ub4e0 \ud654\uba74\uc758 \ud68c\uc804\uc774 \ubc1c\uc0dd\ud558\uba74 onConfigurationChanged()\uac00 \ubd88\ub9ac\uae30 \ub54c\ubb38\uc5d0, \uc774 \uc548\uc5d0\uc11c \uccb4\ud06c\ub97c \ud558\uac8c\ub418\uba74 \ubcc0\uacbd\uc2dc, \ubcc0\uacbd\uc0ac\ud56d\uc744 \uc54c \uc218 \uc788\uac8c\ub41c\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>val display = getSystemService&lt;DisplayManager>()?.getDisplay(Display.DEFAULT_DISPLAY)\nif (display != null) {\n    when(display.rotation) {\n        Surface.ROTATION_0 -> { }\n        Surface.ROTATION_90 -> { }\n        Surface.ROTATION_180 -> { }\n        Surface.ROTATION_270 -> { }\n    }\n\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">val<\/span><span style=\"color: #ADBAC7\"> display <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #DCBDFB\">getSystemService<\/span><span style=\"color: #ADBAC7\">&lt;<\/span><span style=\"color: #F69D50\">DisplayManager<\/span><span style=\"color: #ADBAC7\">&gt;()?.<\/span><span style=\"color: #DCBDFB\">getDisplay<\/span><span style=\"color: #ADBAC7\">(Display.DEFAULT_DISPLAY)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F47067\">if<\/span><span style=\"color: #ADBAC7\"> (display <\/span><span style=\"color: #F47067\">!=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">null<\/span><span style=\"color: #ADBAC7\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">when<\/span><span style=\"color: #ADBAC7\">(display.rotation) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_0 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_90 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_180 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        Surface.ROTATION_270 <\/span><span style=\"color: #F47067\">-&gt;<\/span><span style=\"color: #ADBAC7\"> { }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>\uc774\ub807\uac8c \ud654\uba74 \ud68c\uc804\uc744 \ucc98\ub9ac\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubd24\ub2e4. \uc5b4\ub835\ub2e4\uace0 \ud560 \uc218\ub294 \uc5c6\uc9c0\ub9cc, \uaf64\ub098 \ubc88\uac70\ub86d\uace0 \uae4c\ub2e4\ub85c\uc6cc \ubcf4\uc774\ub294\uac74 \uc0ac\uc2e4. \ubb50, \uadf8\ub798\uc11c \uae30\ub85d\ud574 \ub450\ub824\uace0 \uc791\uc131\ud558\ub294\uac70\ub2c8\uae4c. \uc5ec\uae30\uae4c\uc9c0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ubcf4\ud1b5 \ud654\uba74\uc758 \ud68c\uc804\uc744 \ucc98\ub9ac\ud558\ub294 \uacbd\uc6b0\ub294 \ud654\uba74\uc774 portrait\uc778\uc9c0 landscape\uc778\uc9c0 \uc5ec\ubd80\uc774\ub2e4. \uadf8\ub7ec\ub098, \ub098\uce68\ubc18\ucc98\ub7fc \ud68c\uc804\ubc29\ud5a5\uc5d0 \ub530\ub77c \ubc14\ub298 \uac01\ub3c4\ub97c \ub2e4\ub974\uac8c \uacc4\uc0b0\ud574\uc57c \ud558\ub294 \uacbd\uc6b0\ub77c\uba74, 4\ubc29\ud5a5\uc758 \ud68c\uc804\ubc29\ud5a5\uc744 \ubaa8\ub450 \uc54c\uc544\uc57c\ud55c\ub2e4. \uc5ec\uae30\uc11c\ub294 \ub2e4\ub8e8\uc9c0 \uc54a\uc9c0\ub9cc \uc0ac\uc871\uc744 \ub2ec\uc790\uba74, \ub098\uce68\ubc18\uc740 \ud654\uba74\uc774 \ub4a4\uc9d1\ud600 \uc88c\ud45c\uacc4\uac00 \ub4a4\uc9d1\ud788\ub294 \uacbd\uc6b0\uae4c\uc9c0 \uace0\ub824\ud574\uc57c \ud55c\ub2e4. \ud654\uba74\uc758 \ud604\uc7ac \ud68c\uc804\uc0c1\ud0dc\ub97c \uc54c\uc544\ub0b4\ub294 \ubc29\ubc95 \ud654\uba74\uc758 \ud68c\uc804\uc740 UI\uc601\uc5ed\uc774\uace0, Activity\uc5d0\uc11c \ucc98\ub9ac\ud574\uc57c \ud568\uc744 \uc720\ucd94\ud560 \uc218 \uc788\ub2e4. Fragment\uac00 \uc544\ub2c8\ub77c Activity\uc778 \uc774\uc720\ub294, Fragment\uac00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[186,269,268,264,266,20,265,267],"class_list":["post-1390","post","type-post","status-publish","format-standard","hentry","category-android","tag-android-2","tag-configchanges","tag-onconfigurationchanged","tag-rotation","tag-screen-rotation","tag-android","tag-265","tag-267"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/1390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/comments?post=1390"}],"version-history":[{"count":5,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/1390\/revisions"}],"predecessor-version":[{"id":3474,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/1390\/revisions\/3474"}],"wp:attachment":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/media?parent=1390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/categories?post=1390"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/tags?post=1390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}