PopupWindow-弹窗的界面
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-弹窗的界面的更多相关文章
- Android进阶2之PopupWindow弹窗(有点悬浮窗的感觉)
PopupWindow是一个可以用来显示一个任意的视图的弹出窗口,他需要完全依赖layout布局. 它没什么界面,在弹出的窗口中完全显示布局中的控件. 上面两个美女头就是弹窗PopupWindow显示 ...
- Android 开发 PopupWindow弹窗
简介 PopupWindow,顾名思义弹窗.PopupWindow是与AlertDialog在形式上类似的弹窗功能,都是为了在activity最上层显示一个弹窗.但是区别是PopupWindow可以自 ...
- Android PopupWindow 弹窗背景半透明,设置最大高度
首先讲一个网上的方法: popupwindow弹出后,屏幕背景变成半透明这个效果很普通.实现的方法也很多.我使用的可能是最简单的一种,就是设置一下getWindows的透明度. /** * 设置添加屏 ...
- Android开发 PopupWindow弹窗调用第三方地图(百度,高德)实现导航功能
博客描述:后台返回地点的经纬度在地图上进行描点,点击导航弹出PopupWindow进行选择地图操作,如果手机中没有安装地图,提示没有,否则传值调起地图进行导航操作 看一下实现的效果,没图说再多都白搭 ...
- 使用PopupWindow弹窗提醒
一.新建view.xml 注意里面的控件要一个一个的定义离上一个控件的距离,即margin_top,不然最后的效果是紧缩的 二.在java中定义两个变量 1.View view=null: 2.pop ...
- 【Android UI设计与开发】7.底部菜单栏(四)PopupWindow 实现显示仿腾讯新闻底部弹出菜单
前一篇文章中有用到 PopupWindow 来实现弹窗的功能.简单介绍以下吧. 官方文档是这样解释的:这就是一个弹出窗口,可以用来显示一个任意视图.出现的弹出窗口是一个浮动容器的当前活动. 1.首先来 ...
- react-native聊天室|RN版聊天App仿微信实例|RN仿微信界面
一.前言 9月,又到开学的季节.为每个一直默默努力的自己点赞!最近都沉浸在react native原生app开发中,之前也有使用vue/react/angular等技术开发过聊天室项目,另外还使用RN ...
- Android开发之PopupWindow
/* * Android开发之PopupWindow * * Created on: 2011-8-8 * Author: blueeagle * Email: liujiaxiang@g ...
- Android ——VideoView禁止"无法播放该视频"弹窗
我们在使用videoView播放视频时,如果获取内容失败.网址不对.或者视频格式不对等,会弹出“无法播放该视频”的弹窗,阻塞用户使用. 这种情况,如果在一些自助服务类场合下,弹窗会造成十分不友好的用户 ...
- PopupWindow 的常用api封装
对PopupWindow常用API的简单封装,几行代码就搞定PopupWindow弹窗,使用Builder模式,链式调用,像使用AlertDialog 一样 封装通用PopupWindow,Custo ...
随机推荐
- KM3
本科:读完一本书,知道book里讲的是什么,带有知识吸收: 硕士:读完一本书,知道book里的内容,而且还能发现相关的问题,带有知识的思考: 博士:读完一本书,知道book里的内容,而且还能发现相关的 ...
- Python调用C模块以及性能分析
一.c,ctypes和python的数据类型的对应关系 ctypes type ctype Python type c_char char 1-character string c_wchar wch ...
- WPF 概述
WPF 全称是:Windows Presentation Foundation,直译为Windows表示基础.WPF是专门为GUI(Graphic User Interface)程序开发设计的. 在过 ...
- 1043. Is It a Binary Search Tree
http://www.patest.cn/contests/pat-a-practise/1043 #include <stdio.h> #include <vector> u ...
- 【jquery插件】收藏
http://www.oschina.net/project/tag/356/jquery-file-upload
- mvc简单execl导出
直接上代码: public static byte[] GetExecl(DataTable dt, List<string> list) { var sbHtml = new Strin ...
- Oracle的spool命令
在控制台上使用spool 路径+文件名 命令可以将整个过程写入指定的文件中, 结束使用spool off 命令, 当执行spool off后文件中的内容才能看见; ed命令修改当前缓冲区的上一条命令;
- Qt智能指针简明说明
下面的智能指针分别对应boost库,Qt库,c++11的智能指针 boost::scoped_ptr QScopedPointer unique_ptr 在其生命期结束后会自动删除它所指的对象(确定 ...
- 3D游戏常用技巧Normal Mapping (法线贴图)原理解析——高级篇
1.概述 上一篇博客,3D游戏常用技巧Normal Mapping (法线贴图)原理解析——基础篇,讲了法线贴图的基本概念和使用方法.而法线贴图和一般的纹理贴图一样,都需要进行压缩,也需要生成mipm ...
- centos7 更新yum安装源
系统自带的yum安装源有些软件找不到 这里我们使用阿里云的源 1.加源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/re ...