1 效果图
2 知识点
  PopupWindow(View contentView, int width, int height) //创建一个没有获取焦点、长为width、宽为height,内容为cntentView的popup window. 
  PopupWindow(View contentView, int width, int height, boolean focusable) //类似上面那个,但第四个参数可以控制是否获取焦点 //(这2种使用较多)!!!!
3 弹出框的界面 
 layout_about_popup.xml
<?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="wrap_content"
android:background="@color/bg_about_popup"
android:orientation="vertical" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal" > <LinearLayout
android:id="@+id/ll_share_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > <ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/button_share_1_pressed" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="微信好友"
android:textSize="13sp" />
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" /> <LinearLayout
android:id="@+id/ll_share_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > <ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/button_share_4_pressed" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="微信朋友圈"
android:textSize="13sp" />
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" /> <LinearLayout
android:id="@+id/ll_share_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > <ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/button_share_2_pressed" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="QQ登录"
android:textSize="13sp" />
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" /> <LinearLayout
android:id="@+id/ll_share_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > <ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/button_share_3_pressed" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="微博登录"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout> <ImageView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="5dp"
android:background="@android:color/black" /> <Button
android:id="@+id/btn_share_call_off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@color/transparent"
android:text="取消" /> </LinearLayout>
4 button_share_1_pressed.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/login_share_2_0" android:state_pressed="false"></item>
<item android:drawable="@drawable/login_share_2_1" android:state_pressed="true"></item> </selector>

5 .java

    private LinearLayout layout_weixin;
private LinearLayout layout_weixin_friends;
private LinearLayout layout_qq;
private LinearLayout layout_sina;
private Button btn_out_off;
private View view;
private PopupWindow pop;
    /***
     * 获取PopupWindow实例
     */
    private void getPopupWindow() {         if (null != pop) {
            closePopupWindow();
            return;
        } else {
            initPopuptWindow();
        }
    }
    /**
     * 创建PopupWindow
     */
    protected void initPopuptWindow() {         // PopupWindow实例化
        pop = new PopupWindow(view, LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT, true);
        pop.setAnimationStyle(R.style.MenuAnimationFade);
        // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
        pop.showAtLocation(tv_about_version, Gravity.BOTTOM, 0, 0);
        WindowManager.LayoutParams params = this.getWindow().getAttributes();
        params.alpha = 0.5f;
        this.getWindow().setAttributes(params);         view.setOnTouchListener(new View.OnTouchListener() {             @Override
            public boolean onTouch(View v, MotionEvent event) {
                closePopupWindow();
                return false;
            }
        });
    }
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ic_about_back:
finish();
break;
case R.id.ic_about_help:
Uri uri = Uri.parse("http://www.etoury.com/help/app.html");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
break;
case R.id.btn_about_share:   getPopupWindow();
break;
case R.id.ll_share_1:
finish();
break;
case R.id.ll_share_2:
finish();
break;
case R.id.ll_share_3:
finish();
break;
case R.id.ll_share_4:
finish();
break;
case R.id.btn_share_call_off:
closePopupWindow();
break;
default:
break;
} }
    /**
     * 关闭窗口
     */
    private void closePopupWindow() {
        if (pop != null && pop.isShowing()) {
            pop.dismiss();
            pop = null;
            WindowManager.LayoutParams params = this.getWindow()
                    .getAttributes();
            params.alpha = 1f;
            this.getWindow().setAttributes(params);
        }
    }

PopupWindow-弹窗的界面的更多相关文章

  1. Android进阶2之PopupWindow弹窗(有点悬浮窗的感觉)

    PopupWindow是一个可以用来显示一个任意的视图的弹出窗口,他需要完全依赖layout布局. 它没什么界面,在弹出的窗口中完全显示布局中的控件. 上面两个美女头就是弹窗PopupWindow显示 ...

  2. Android 开发 PopupWindow弹窗

    简介 PopupWindow,顾名思义弹窗.PopupWindow是与AlertDialog在形式上类似的弹窗功能,都是为了在activity最上层显示一个弹窗.但是区别是PopupWindow可以自 ...

  3. Android PopupWindow 弹窗背景半透明,设置最大高度

    首先讲一个网上的方法: popupwindow弹出后,屏幕背景变成半透明这个效果很普通.实现的方法也很多.我使用的可能是最简单的一种,就是设置一下getWindows的透明度. /** * 设置添加屏 ...

  4. Android开发 PopupWindow弹窗调用第三方地图(百度,高德)实现导航功能

    博客描述:后台返回地点的经纬度在地图上进行描点,点击导航弹出PopupWindow进行选择地图操作,如果手机中没有安装地图,提示没有,否则传值调起地图进行导航操作 看一下实现的效果,没图说再多都白搭 ...

  5. 使用PopupWindow弹窗提醒

    一.新建view.xml 注意里面的控件要一个一个的定义离上一个控件的距离,即margin_top,不然最后的效果是紧缩的 二.在java中定义两个变量 1.View view=null: 2.pop ...

  6. 【Android UI设计与开发】7.底部菜单栏(四)PopupWindow 实现显示仿腾讯新闻底部弹出菜单

    前一篇文章中有用到 PopupWindow 来实现弹窗的功能.简单介绍以下吧. 官方文档是这样解释的:这就是一个弹出窗口,可以用来显示一个任意视图.出现的弹出窗口是一个浮动容器的当前活动. 1.首先来 ...

  7. react-native聊天室|RN版聊天App仿微信实例|RN仿微信界面

    一.前言 9月,又到开学的季节.为每个一直默默努力的自己点赞!最近都沉浸在react native原生app开发中,之前也有使用vue/react/angular等技术开发过聊天室项目,另外还使用RN ...

  8. Android开发之PopupWindow

      /* *  Android开发之PopupWindow * *  Created on: 2011-8-8 *  Author: blueeagle *  Email: liujiaxiang@g ...

  9. Android ——VideoView禁止"无法播放该视频"弹窗

    我们在使用videoView播放视频时,如果获取内容失败.网址不对.或者视频格式不对等,会弹出“无法播放该视频”的弹窗,阻塞用户使用. 这种情况,如果在一些自助服务类场合下,弹窗会造成十分不友好的用户 ...

  10. PopupWindow 的常用api封装

    对PopupWindow常用API的简单封装,几行代码就搞定PopupWindow弹窗,使用Builder模式,链式调用,像使用AlertDialog 一样 封装通用PopupWindow,Custo ...

随机推荐

  1. 自动化运维——一键安装MySQL

    根据项目需要,前段时间在搞EMM系统各种安装包的自动化部署工作,主要包括一键安装和一键启动\停止功能.总结记录下来,以供后用. 本文主要是自动安装MySQL5.7.11版,Linux版脚本在CentO ...

  2. ORA-27102: out of memory并伴随OSD-00031的处理

    刚才客户电话过来说有个数据库起不来了,开发商搞了好久搞不掂,得要让我们去帮忙看看.过去到现场,发现数据库无法打开,连nomount模式都不可以.报错的内容大致如下: ORA-27102: out of ...

  3. 【maven项目结构】module 生成独立的jar

    生成jar 生成jar的过程会出现以下问题: clean完了之后就会出现以下问题: install [INFO] Scanning for projects... [INFO] [INFO] ---- ...

  4. Timeline

    Timeline面板   Chrome开发者工具详解(3)-Timeline面板 注: 这一篇主要讲解面板Timeline,参考了Google的相关文档,主要用于公司内部技术分享.. 更新时间:201 ...

  5. 语音合成,语音播报功能(系统)-b

    第一次接触语音合成,只实现了很简单的功能,记录一下,以后免得去网上四处找资料 最近在做高德地图导航的时候有个语音播报的功能,高德sdk已经提供了要语音的字符串.我要做的就是把这些字符串读出声音来即可. ...

  6. 在 Windows 8 或 8.1 上安装 .NET Framework 3.5 安装错误:0x800f0906、0x800F081F

    昨天给一天新装Windows 8.1的PC装.NET Framework 3.5 发现联网速度很慢,并且在长久等待过后直接报错了:0x800f0906 经过Bing,发现了解决方案: 如果根据需要安装 ...

  7. centos apache 隐藏和伪装 版本信息

    1.隐藏Apache版本信息 测试默认 apache 的状态信息[root@1314it conf]# curl -Is localhostHTTP/1.1 200 OKDate: Tue, 16 N ...

  8. sshj ,ssh , springmvc pom.xml

    记录下项目中的 pom文件 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ ...

  9. Matlab计算矩阵间距离

    夜深人静时分,宿舍就我自己,只有蚊子陪伴着我,我慢慢码下这段文字............ 感觉知识结构不完善:上学期看论文,发现类间离散度矩阵和类内离散度矩阵,然后百度,找不到,现在学模式识别,见了, ...

  10. CNKI翻译助手-连接数据库失败

    IP并发数限制,老师说西工大的CNKI才20个并发指标,HPU自不必说.但是我略表怀疑,这只是翻译助手而已,就像百度翻译和百度数据库的区别,如何验证呢?去校外用该助手,如果能用,那么就不是IP并发限制 ...