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. Vb.Net Xml文档格式化

    最近在处理Webservice文档的时候,因为是未格式化的,需要处理,所以有了以下代码. #Region "Xml字符串转换成格式化的XML文件" 'txt_Result.Text ...

  2. Linux进程间通信IPC学习笔记

    linux下的进程通信手段基本上是从Unix平台上的进程通信手段继承而来的.而对Unix发展做出重大贡献的两大主力AT&T的贝尔实验室及BSD(加州大学伯克利分校的伯克利软件发布中心)在进程间 ...

  3. SIM900A访问HTTP的简单方法

    最近做项目,使用Arduino控制设备,读取数据,然后通过移动网络传送到服务器. 我选用的是正点原子的SIM900A模块.在服务器部署了一个监听程序,Arduino控制SIM900A通过TCP方式把数 ...

  4. Java - 选择性排序 PHP || Java 代码对比

    int [] array1 = {1,3,5,7,9,10,2,15,154,10,2,188,200};//定义一个数组,内容为混乱大小 int index = 0;//定义一个最大值或最小值的位置 ...

  5. DemoExample

    <HTML> <HEAD> <TITLE>使用递归求解斐波那契数列</TITLE> </HEAD> <BODY> <?ph ...

  6. 实时数据处理环境搭建flume+kafka+storm:4.storm安装配置

    1.解压 apache-storm-0.9.3.tar.gz   2.修改配置文件 conf/storm.yaml --zk地址  storm.zookeeper.servers:  - " ...

  7. maven eclipse web项目流程(简化内容)

    1.maven eclipse 环境搭建 1.1 下载解压配置环境变量(解压.环境变量maven目录到bin.setting.xml 改本地仓库) 1.2 eclipse插件安装配置(link安装.加 ...

  8. maven 解决 Eclipse is running in a JRE, but a JDK is

    解决安装了maven插件的myeclipse每次开启报错 The Maven Integration requires that Eclipse be running in a JDK, becaus ...

  9. CodeForces 32C

    额  找找规律吧  要用long long 才过. #include <cstdio> #include <algorithm> using namespace std; in ...

  10. uva 10051

    将每一个分解为六个两面的 简单地dp 回溯输出路径..... #include <cstdio> #include <cstring> #include <cmath&g ...