欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

前言

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


效果圖

如圖可以看出,當(dāng)前的窗體,第一眼其實和dialog沒有什么區(qū)別,但是它是自定義activity實現(xiàn)。如何實現(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="語音球開啟方式"
  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><!--無標(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é)

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

相關(guān)文章

  • Android CountDownTimer案例總結(jié)

    Android CountDownTimer案例總結(jié)

    這篇文章主要介紹了Android CountDownTimer案例總結(jié),本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • Android App打包加固后的APK無法安裝問題解決

    Android App打包加固后的APK無法安裝問題解決

    Android應(yīng)用當(dāng)中,很多隱私信息都是以 字符串的形式存在的,所以需要加密,本文主要介紹了Android App打包加固后的APK無法安裝問題解決,感興趣的可以了解一下
    2024-01-01
  • Android通過自定義Activity實現(xiàn)懸浮的Dialog詳解

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

    這篇文章主要給大家介紹了關(guān)于Android通過自定義Activity實現(xiàn)懸浮的Dialog的相關(guān)資料,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),對大家具有一定的參考學(xué)習(xí)價值,感興趣的朋友們下面來一起看看吧。
    2017-05-05
  • Flutter利用注解生成可自定義的路由的實現(xiàn)

    Flutter利用注解生成可自定義的路由的實現(xiàn)

    這篇文章主要介紹了Flutter利用注解生成可自定義的路由的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Android入門之使用SharedPreference存取信息詳解

    Android入門之使用SharedPreference存取信息詳解

    這篇文章主要為大家詳細(xì)介紹了Android如何使用SharedPreference實現(xiàn)存取信息,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)Android有一定的幫助,需要的可以參考一下
    2022-12-12
  • Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(一)

    Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(一)

    這篇文章主要介紹了Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(一) 的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • Android實現(xiàn)自定義帶刪除功能的EditText實例

    Android實現(xiàn)自定義帶刪除功能的EditText實例

    本篇文章主要介紹了Android實現(xiàn)自定義帶刪除功能的EditText實例,非常具有實用價值,需要的朋友可以參考下
    2017-06-06
  • Android使用Handler實現(xiàn)倒計時功能

    Android使用Handler實現(xiàn)倒計時功能

    這篇文章主要為大家詳細(xì)介紹了Android使用Handler實現(xiàn)倒計時功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • Android中刪除文件以及文件夾的命令記錄

    Android中刪除文件以及文件夾的命令記錄

    這篇文章主要介紹了Android中刪除文件以及文件夾的命令,需要的朋友可以參考下
    2013-06-06
  • Android+Flutter實現(xiàn)文字跑馬燈特效

    Android+Flutter實現(xiàn)文字跑馬燈特效

    跑馬燈常常被運用在很多領(lǐng)域, 例如商場的電子條幅、大樓的宣傳廣告位、地鐵的廣告位。今天我們來說一下flutter 怎么通過繪制來實現(xiàn)跑馬燈效果!,希望對大家有所幫助
    2022-11-11

最新評論