Android实现系统级全局的PopupWindow(随时弹出)

本文详细介绍了如何在Android中实现系统级全局的PopupWindow,包括清单文件的权限声明,PopupWindow的布局设计,WindowUtils工具类的编写以及如何动态申请权限进行弹窗操作。
摘要由CSDN通过智能技术生成

1.  清单文件声明权限

<!-- 显示顶层浮窗 -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

2. 全局的PopupWindow的布局文件(total_popup_window.xml ) :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_gravity="center"
    android:background="#ededed"
    android:gravity="center"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:id="@+id/popup_window"
        android:layout_width="300dp"
        android:layout_height="200dp"
        android:background="#ffffff"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="44dp"
            android:gravity="center"
            android:text="标题"
            android:textColor="#000000"
            android:textSize="18sp" />
        <View
            android:id="@+id/title_divider"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_below="@id/title"
            android:background="#ededed" />
        <TextView
            android:id="@+id/content"
            android:layout_centerVertical="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_below="@id/title_divi
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值