当前位置:操作系统 > 安卓/Android >>

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>

 

 

 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,