Interesting/ANDROID | Posted by hyena0 2008. 1. 9. 00:58

[안드로이드]투명바탕 만들기

투명바탕만들기

투명바탕의 APP를 만들려면 다음의 절차를 거치면 된다.

1. AndroidMenifest.xml 파일을 녹색부분과 같이 수정한다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.transp">
    <application android:icon="@drawable/icon" android:theme="@android:style/Theme.Dark">
        <activity class=".transp" android:label="@string/app_name" android:theme="@style/Theme.Transparent">
            <intent-filter>
                <action android:value="android.intent.action.MAIN" />
                <category android:value="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

2. style 을 추가하고, 투명한 값의 정의를 내린다.
 개발하는 안드로이드 폴더중 values 내에 styles.xml , colors.xml 파일을 아래와 같이 추가한다.

styles.xml
<?xml version="1.0" encoding="utf-8" ?>
 <resources>
  <style name="app_name" />

 <style name="app_name.Transparent">
  <item name="android:windowBackground">@drawable/draw_background</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:foregroundColor">#fff</item>
  </style>
  </resources>

colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
     <drawable name="transparent_background">#a0000000</drawable>
</resources>

3. 메인함수에서 해당  xml을 호출한다.

  setContentView(R.layout.xml_name);