達到的效果就像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"即可,效果如下:
在網上搜了一下,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了。

新聞熱點
疑難解答