最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android通過(guò)自定義Activity實(shí)現(xiàn)懸浮的Dialog詳解

 更新時(shí)間:2017年05月26日 14:10:34   作者:ROOM先生  
這篇文章主要給大家介紹了關(guān)于Android通過(guò)自定義Activity實(shí)現(xiàn)懸浮的Dialog的相關(guān)資料,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,感興趣的朋友們下面來(lái)一起看看吧。

前言

其實(shí)實(shí)現(xiàn)懸浮的自定義窗體有很多方法,自定義Dialog,自定義layout 均可以實(shí)現(xiàn)。自定義activity也是可以的,今天我就介紹一下activity的實(shí)現(xiàn)方法。下面來(lái)看看詳細(xì)的介紹:


效果圖

如圖可以看出,當(dāng)前的窗體,第一眼其實(shí)和dialog沒(méi)有什么區(qū)別,但是它是自定義activity實(shí)現(xiàn)。如何實(shí)現(xiàn)的呢?

代碼如下:

新建activity

@Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 this.requestWindowFeature(Window.FEATURE_NO_TITLE);
 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  WindowManager.LayoutParams.FLAG_FULLSCREEN);
 setContentView(R.layout.dialog_show_display_mode);
 WindowManager windowManager = getWindowManager();
 Display display = windowManager.getDefaultDisplay();
 WindowManager.LayoutParams params = getWindow().getAttributes();
// params.height = (int) (display.getHeight() * 0.3);
// params.width = (int) (display.getWidth() * 0.8);
 params.alpha = 1.0f;
 getWindow().setAttributes(params);
 getWindow().setGravity(Gravity.CENTER);
}

layout樣式布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:orientation="vertical">

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="45dp">

 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:layout_marginLeft="20dp"
  android:text="語(yǔ)音球開(kāi)啟方式"
  android:textColor="@color/bg_black"
  android:textSize="20dp" />
 </LinearLayout>

 <View
 android:layout_width="match_parent"
 android:layout_height="1dp"
 android:background="@color/forget_password" />

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical">

 <LinearLayout
  android:id="@+id/display_dialog_intelligence_linner"
  android:layout_width="match_parent"
  android:layout_height="65dp"
  android:orientation="horizontal">

  <ImageView
  android:id="@+id/display_dialog_intelligence_iv"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:src="@mipmap/abc_btn_radio_to_on_mtrl_000" />

  <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:layout_marginLeft="10dp"
  android:text="智能顯示"
  android:textColor="@color/colorGreen2" />
 </LinearLayout>

 <View
  android:layout_width="match_parent"
  android:layout_height="1dp"
  android:background="@color/forget_password" />

 <LinearLayout
  android:id="@+id/display_dialog_custom_linner"
  android:layout_width="match_parent"
  android:layout_height="65dp"
  android:orientation="horizontal">

  <ImageView
  android:id="@+id/display_dialog_custom_iv"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:src="@mipmap/abc_btn_radio_to_on_mtrl_000" />

  <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:layout_marginLeft="10dp"
  android:text="自定義顯示"
  android:textColor="@color/colorGreen2" />
 </LinearLayout>
 </LinearLayout>
</LinearLayout>

style樣式:

<style name="activityTheme" parent="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
 <item name="android:windowFrame">@null</item><!--邊框-->
 <item name="android:windowIsFloating">true</item><!--是否浮現(xiàn)在activity之上-->
 <item name="android:windowIsTranslucent">false</item><!--半透明-->
 <item name="android:windowNoTitle">true</item><!--無(wú)標(biāo)題-->
 <item name="android:background">@android:color/transparent</item>
 <item name="android:windowBackground">@android:color/transparent</item><!--背景透明-->
 <item name="android:backgroundDimEnabled">true</item><!--模糊-->
 </style>

資源文件配置activity:

<activity
  android:name=".__activity.FloatWindowDialogActivity"
  android:screenOrientation="portrait"
  android:theme="@style/activityTheme" />

ok 搞定。

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

相關(guān)文章

  • android app判斷是否有系統(tǒng)簽名步驟詳解

    android app判斷是否有系統(tǒng)簽名步驟詳解

    這篇文章主要為大家介紹了android app判斷是否有系統(tǒng)簽名步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • 一文詳解?Compose?Navigation?的實(shí)現(xiàn)原理

    一文詳解?Compose?Navigation?的實(shí)現(xiàn)原理

    這篇文章主要介紹了一文詳解?Compose?Navigation的實(shí)現(xiàn)原理,文章通告圍繞主題展開(kāi)詳細(xì)的相關(guān)內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-08-08
  • Android中在GridView網(wǎng)格視圖上實(shí)現(xiàn)item拖拽交換的方法

    Android中在GridView網(wǎng)格視圖上實(shí)現(xiàn)item拖拽交換的方法

    這篇文章主要介紹了Android中在GridView上實(shí)現(xiàn)item拖拽交換效果的方法,比起ListView的列表?xiàng)l目交換稍顯復(fù)雜,文中先介紹了關(guān)于創(chuàng)建GridView的一些基礎(chǔ)知識(shí),需要的朋友可以參考下
    2016-04-04
  • Android實(shí)現(xiàn)全局懸浮框

    Android實(shí)現(xiàn)全局懸浮框

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)全局懸浮框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-01-01
  • Android?使用壓縮紋理的方案

    Android?使用壓縮紋理的方案

    這篇文章主要介紹了Android?使用壓縮紋理,本文介紹了什么是壓縮紋理,以及加載壓縮紋理的核心步驟,并在 Android OpenGLES 平臺(tái)上實(shí)現(xiàn)了壓縮紋理的顯示,需要的朋友可以參考下
    2022-09-09
  • Assert.assertEquals()方法參數(shù)詳解

    Assert.assertEquals()方法參數(shù)詳解

    本文詳細(xì)講解了Assert.assertEquals()方法參數(shù),文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-12-12
  • android仿音悅臺(tái)頁(yè)面交互效果實(shí)例代碼

    android仿音悅臺(tái)頁(yè)面交互效果實(shí)例代碼

    這篇文章主要介紹了android 仿音悅臺(tái)頁(yè)面播放效果實(shí)例代碼,新版的音悅臺(tái) APP 播放頁(yè)面交互非常有意思,可以把播放器往下拖動(dòng),然后在底部懸浮一個(gè)小框,還可以左右拖動(dòng)。
    2017-01-01
  • RecyclerView實(shí)現(xiàn)側(cè)滑和網(wǎng)絡(luò)斷點(diǎn)續(xù)傳

    RecyclerView實(shí)現(xiàn)側(cè)滑和網(wǎng)絡(luò)斷點(diǎn)續(xù)傳

    這篇文章主要為大家詳細(xì)介紹了RecyclerView實(shí)現(xiàn)側(cè)滑和網(wǎng)絡(luò)斷點(diǎn)續(xù)傳,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Android5.0+ CollapsingToolbarLayout使用詳解

    Android5.0+ CollapsingToolbarLayout使用詳解

    這篇文章主要為大家詳細(xì)介紹了Android5.0+ CollapsingToolbarLayout使用,感興趣的小伙伴們可以參考一下
    2016-09-09
  • Android  調(diào)用系統(tǒng)應(yīng)用的方法總結(jié)

    Android 調(diào)用系統(tǒng)應(yīng)用的方法總結(jié)

    這篇文章主要介紹了Android 調(diào)用系統(tǒng)應(yīng)用的方法總結(jié)的相關(guān)資料,這里提供調(diào)用錄像,錄音,拍照等功能,需要的朋友可以參考下
    2017-08-08

最新評(píng)論

鄂伦春自治旗| 长乐市| 彩票| 抚远县| 元谋县| 葫芦岛市| 南阳市| 延津县| 桑日县| 南投市| 弥渡县| 永春县| 河间市| 开阳县| 平谷区| 临洮县| 万年县| 青田县| 根河市| 昌宁县| 湛江市| 襄垣县| 娱乐| 张掖市| 嘉鱼县| 南靖县| 桐梓县| 柳林县| 田东县| 鹿泉市| 翁源县| 迭部县| 天台县| 威海市| 噶尔县| 横峰县| 漳浦县| 图木舒克市| 淮阳县| 郴州市| 旬阳县|