Android 毛玻璃效果对话框

本文介绍了如何在Android中创建具有毛玻璃效果的对话框。通过使用原界面截图并应用高斯模糊,实现了popwindow的背景效果。提供了两种不同的布局实现方式,包括设置圆角背景的XML以及在弹出窗口上方添加透明ImageView来达到模糊效果。
摘要由CSDN通过智能技术生成

一个popwindow,在弹出的时候背景是原界面的截图加高斯模糊效果


先给出popwindow的布局文件

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/roundcorner" >

    <com.npi.blureffect.ScrollableImageView
        android:id="@+id/imageView1"
        android:background="@drawable/roundcorner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/roundcorner" />

    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="false"
            android:layout_alignParentTop="false"
            android:layout_centerHorizontal="true"
            android:layout_centerInParent="false"
            android:layout_centerVertical="false"
            android:layout_marginLeft="33dp"
            android:layout_marginTop="44dp"
            android:text="这是提示语" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="false"
            android:layout_below="@+id/textView1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="49dp"
            android:text="确定"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>

</FrameLayout>
</pre>里面那个自定义imageView控件在我上一篇博客里<p></p><p>下面是activity的布局</p><p></p><pre name="code" class="html"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/window"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.npi.blureffect.TestActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <RatingBar
        android:id="@+id/ratingBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="124dp" />

    <Switch
        android:id="@+id/switch1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/ratingB
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值