将一个activity以对话框的形式悬浮在另一个activity之上
2017-02-08 13:58
393 查看
本篇文章主要介绍了"将一个activity以对话框的形式悬浮在另一个activity之上",主要涉及到将一个activity以对话框的形式悬浮在另一个activity之上方面的内容,对于将一个activity以对话框的形式悬浮在另一个activity之上感兴趣的同学可以参考一下。
dialog activity android theme
达到的效果就像google自带的搜索widiget中,点击录音键弹出的对话框效果一样
除了一个dialog,没有其他的东西,而且背景是半透明的。
在网上搜了一下,android自带theme如下:
•android:theme="@android:style/Theme.Dialog" 将一个Activity显示为对话框模式
•android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏
•android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏
•android:theme="Theme.Light" 背景为白色
•android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏
•android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏
•android:theme="Theme.Black" 背景黑色
•android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏
•android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏
•android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景
•android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏
•android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏
•android:theme="Translucent"
•android:theme="Theme.Translucent.NoTitleBar"
•android:theme="Theme.Translucent.NoTitleBar.Fullscreen"
•android:theme="Theme.Panel"
•android:theme="Theme.Light.Panel"
其实,只要在manifest.xml文件中把<application>中设置为android:theme = "@android:style/Theme.Dialog"即可,效果如下:
在这个activity中添加去除标题栏的语句 requestWindowFeature(Window.FEATURE_NO_TITLE);
设置Activity的背景为透明色
1.先在res/valaus/下新建color.xm.文件,内容包括:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#CCCCCCCC</color> <!-- 白色 -->
<color name="darkgray">#A9A9A9</color> <!-- 暗灰色 -->
<color name="transparent">#0000</color> <!-- 透明色 -->
</resources>
2.在Activity实现中的OnCreat()方法中添加语句:
Resources res = getResources();
Drawable drawable = res.getDrawable(R.color.touming);
this.getWindow().setBackgroundDrawable(drawable);
即可。
《二》。
要让activity 的UI不显示,只是让一个activity 做某一件事情,可以设置主题为android:theme="@android:style/Theme.Translucent.NoTitleBar";
其中"@android:style/Theme.Translucent.NoTitleBar"的实现是在theme.xml文件中,进入这个theme.xml文件,<style name="Theme.Translucent.NoTitleBar">风格定义:
<style name="Theme.Translucent.NoTitleBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
</style>
对比原来系统生成的是:
<style name="Theme.Translucent.NoTitleBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
多了最后一行:<item name="android:windowBackground">@null</item>;OK了。
相关文章推荐
- 将一个Activity设置成对话框形式
- C#将一个窗体作为另一个窗体的对话框形式弹出
- 一个activity悬浮在另一个activity上,背景透明化效果
- 安装指定apk, 在一个APK中调用另外一个APK的Activity ,在一个应用程序中安装另一个应用APK文件
- vc中如何拷贝一个工程的对话框 资源到另一个工程中?
- 在一个Activity bull中启动另一个Activity secondbull的方法 3 启动package *com.example.android.notepad 中的类bull*
- 在一个Android application 调用另一个 application 里的 Activity 和 Service
- 在一个对话框中访问另一个对话框的变量
- 在一个对话框中显示另一个对话框
- 在VC++中的MFC利用一个dialoge对话框中按钮调用另一个dialoge对话框
- 在一个程序启动另一个程序的Activity
- 在一个Android application 调用另一个 application 里的 Activity 和 Service
- 如何在一个对话框中调用另一个对话框中的数据
- startActivity方法启动一个新的activity时怎么让新的activity在另一个新的 task中
- Android在一个应用中启动另一个应用的Activity时失败的解决办法
- 怎样把一个程序中的对话框资源和对话框类移植到另一个程序中
- 在VC中如何将一个对话框和相应的类完全移植到另一个工程中....
- Android 开发一个Activity 启动另一个Activity碰到的一个问题
- 在一个Activity中启另一个Activity的方法
- Android Sample Code之API Demos (Activity四): 一个activity接收另一个activity结果