国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

將一個activity以對話框的形式懸浮在另一個activity之上

2019-11-09 17:10:24
字體:
來源:轉載
供稿:網友

本篇文章主要介紹了"將一個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了。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贡嘎县| 子洲县| 灵武市| 丹巴县| 前郭尔| 大宁县| 怀集县| 沙河市| 铁岭县| 同德县| 深水埗区| 县级市| 个旧市| 麦盖提县| 南投县| 富民县| 大渡口区| 石林| 陈巴尔虎旗| 济阳县| 井陉县| 张家界市| 祥云县| 锦屏县| 甘南县| 五指山市| 自贡市| 彭州市| 巴东县| 潞城市| 天镇县| 九龙城区| 大渡口区| 揭东县| 太仆寺旗| 石河子市| 宁化县| 德格县| 当雄县| 云浮市| 德格县|