본문 바로가기

Daily Sample

[Day11] Android Custom Dialog theme 적용 소스

TITLE : Android Custom Dialog theme

Date : 2010/06/15

Writen by Dayyoung

Description :

This is Source that Apply the Custom Dialog theme.

Download Link : 

Reference Site: http:android-town.org

안드로이드 화면구성의 기본은 Activity단위로 이루어져 있다.

Acticity의 모양은 단순해서 윈도우 상위창을 날리거나 사용자테마를 적용해서 화면을 구성하면 좋을 수 있다.

1. 처음 Activity에서 세로모드로 변경되지 않도록 강제로 고정한다.

Manifest.xml  에서변경>

<activity android:name=”.MainActivity”
android:label=”@string/app_name”
android:screenOrientation=”portrait”>

설정 후, 화면을 기울여도 화면이 고정된다.

 

2. OnCreate부분에 쓰레드를 실행하여 화면 시작후 2초후에 OptionMenu가 나타나도록 했다.

new Handler().postDelayed(new Runnable() {
public void run() {
openOptionsMenu();
}
}, 2000);

 

3. ListTest 아이콘을 클릭했을 때 Dialog Theme가 적용된 ListView Activity가 실행된다.

Manifest.xml  에서변경>

<activity android:name=”.TestListActivity”
android:label=”@string/app_name”
android:theme=”@android:style/Theme.Dialog”>
</activity>

 

4. 뒷배경을 날리지 않았을 경우 아래 그림과 같이 뒷배경이 남게되어 보기좋지 않다.


5. AboutTest 아이콘을 클릭했을 때 Dialog Theme가 적용된 또 다른 Activity가 실행되는데 앞전과 다른 점은 Background를 뒷배경으로 처리했다는 점이다.

또한  requestWindowFeature(Window.FEATURE_NO_TITLE) 명령으로 타이틀 바를 제거하였다.

AboutActivity.class 에서 뒷배경 제거>

theme.applyStyle(style.Theme_Panel, true);

Manifest.xml  에서변경>

<activity android:name=”.AboutActivity”
android:label=”@string/app_name”
android:theme=”@android:style/Theme.Dialog”>
</activity>

이 밖에도 Activity 구성요소들은 다양한 Theme를 적용할 수 있다.


Creative Commons License
이 저작물은 크리에이티브 커먼즈 저작자표시 3.0 Unported 라이선스에 따라 이용할 수 있습니다.