Language/Android

Wallpaper Activity Demo

아르비스 2010. 6. 15. 17:01

1. Project 생성
package sncap.android.apis;

import sncap.android.apis.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;

public class WallpaperDemos extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.translucent_background);
    }
}

2. translucent_background.xml 추가
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    android:text="Wallpaper Translucent"/>

3. Manifest 수정
<uses-permission android:name="android.permission.SET_WALLPAPER" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".WallpaperDemos"
                  android:label="Wallpaper Test"
                  android:theme="@style/Theme.Wallpaper">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

wallpaper 관련 permission 추가 및 style theme 지정

4. values 에 styles.xml 추가
<resources>
    <style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper">
        <item name="android:colorForeground">#fff</item>
    </style>
</resources>

이전에 test한 Translucent 에서 배경 관련 부분만 변경된 내용이다.