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

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

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

2019-11-09 15:57:16
字體:
來源:轉載
供稿:網友

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 清涧县| 丰顺县| 昌吉市| 无棣县| 佛教| 乐陵市| 丹棱县| 曲水县| 拉孜县| 武邑县| 高邑县| 北碚区| 马关县| 竹北市| 册亨县| 合水县| 吐鲁番市| 上杭县| 永嘉县| 沅陵县| 巴塘县| 资中县| 河北省| 汝城县| 青田县| 偏关县| 曲水县| 苍南县| 湖北省| 库车县| 镇原县| 中山市| 石渠县| 武冈市| 深圳市| 乐平市| 永宁县| 金川县| 遵义市| 江西省| 南乐县|