Android 底部彈出提示窗口覆蓋MENU

 

——————————————-MainActivity.java

package com.example.pup;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

   @Override
public boolean onKeyDown(
int keyCode, KeyEvent event) {
// TODO 自動生成的方法存根
  if (keyCode==KeyEvent.KEYCODE_MENU){
  Intent intent=new Intent(MainActivity.this,Pop.class);
startActivity(intent);
}
return super.onKeyDown(keyCode, event);
}
}

 

 

——————————-Pop .java

package com.example.pup;

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

public class Pop extends Activity {
@Override
protected void onCreate(
Bundle savedInstanceState) {
// TODO 自動生成的方法存根
super.onCreate(savedInstanceState);
setContentView(R.layout.alert_dialog);

}

}

 

 

———————————-MANIFEST.XML

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.pup"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Pop"
            android:theme="@style/MyDialogStyleBottom" />
    </application>

</manifest>

 

 

 

 

 

———-STYLES

<resources>

    <style name="AppTheme" parent="android:Theme.Light" />

    <style name="AnimBottom" parent="@android:style/Animation">
        <item name="android:windowEnterAnimation">@anim/push_bottom_in2</item>
        <item name="android:windowExitAnimation">@anim/push_bottom_out</item>
    </style>
   
    <style name="MyDialogStyleBottom" parent="android:Theme.Dialog">
        <item name="android:windowAnimationStyle">@style/AnimBottom</item>
        <item name="android:windowFrame">@null</item>
        <!– 邊框 –>
        <item name="android:windowIsFloating">true</item>
        <!– 是否浮現在activity之上 –>
        <item name="android:windowIsTranslucent">true</item>
        <!– 半透明 –>
        <item name="android:windowNoTitle">true</item>
        <!– 無標題 –>
        <item name="android:windowBackground">@android:color/transparent</item>
        <!– 背景透明 –>
        <item name="android:backgroundDimEnabled">true</item>
        <!– 模糊 –>
    </style>

</resources>

 

 

 

You May Also Like