안드로이드 Activity를 Dialog처럼
Android 2015. 1. 29. 18:161. 사용할 Dialog 테마를 설정합니다.
res/values/styles.xml
<resources>
....(생략)
<style name="DialogFullScreen" parent="@android:style/Theme.Dialog">
<item name="android:windowFullscreen">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
2. 팝업으로 사용할 activity 를 생성하고,
3. AndroidManifest.xml 을 수정합니다. 팝업으로 사용할 activity의 테마를 설정해줌.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
.. (생략)
<activity
android:name=".PopTest"
android:label="@string/title_activity_pop_test"
android:screenOrientation="landscape"
// 앞서 style.xml에서 생성한 dialog테마를 설정
android:theme="@style/DialogFullScreen" >
</activity>
</application>
</manifest>
- 화면의 Dialog 크기 수정하기
activity의 setContentView 이후에
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = (int) (display.getWidth() * 0.7); //Display 사이즈의 70%
int height = (int) (display.getHeight() * 0.9); //Display 사이즈의 90%
getWindow().getAttributes().width = width;
getWindow().getAttributes().height = height;