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 ...
随机推荐
- MSP430F4152串口操作
/**********************************************************************/ /* 名称:串口通讯 功能:将接到的数据组后原封不 ...
- Python数据结构————二叉查找树的实现
对于二叉查找树的每个节点Node,它的左子树中所有的关键字都小于Node的关键字,而右子树中的所有关键字都大于Node的关键字. 二叉查找树的平均深度是O(log N). 1.初始化 class Bi ...
- 在win7上建立本地FTP站点详细步骤
一.安装FTP组件点击:控制面板—>程序和功能—>打开或关闭Windows功能. 勾选“FTP服务器”及“FTP服务”“FTP扩展性”,点击“确定”,安装FTP组件. 勾选Web管理工具的 ...
- ENVI栅格文件增强后将LUT保存完输出img图像进行分类
ENVI栅格文件储存 图像原始的DN(Digital Number)值记录图像的光谱信息,不能轻易更改。在窗口中显示的一般是经过拉伸等增强处理的LUT上的灰度值,在保存文件时,就有不同的方式。 1. ...
- Java中的break与continue区别
break跳出当前循环执行循环下面的程序, 如果break出现在嵌套循环的内层循环, 则break语句只会跳出当前层的循环; 当程序执行到continue时时, 则跳过本次循环程序重新回到循环开始继续 ...
- 强连通分量Tarjan模板
#include<iostream> #include<stdio.h> #include<string.h> #include<stack> #inc ...
- 实时数据处理环境搭建flume+kafka+storm:2.flume 安装
1. 解压 tar -zxvf 2.配置 拷贝配置文件 :cp flume-conf.properties.template flume-conf.properties ...
- 1034: [ZJOI2008]泡泡堂BNB - BZOJ
Description 第XXXX届NOI期间,为了加强各省选手之间的交流,组委会决定组织一场省际电子竞技大赛,每一个省的代表队由n名选手组成,比赛的项目是老少咸宜的网络游戏泡泡堂.每一场比赛前,对阵 ...
- mac下设置maven环境
在mac系统下设置maven环境. 1.首先通过终端打开 .bash_profile 2.设置maven解压后的路径地址 环境变量设置如下: MAVEN_HOME .PATH 两个变量即可 3. ...
- Matlab划分测试集和训练集
% x是原数据集,分出训练样本和测试样本 [ndata, D] = size(X); %ndata样本数,D维数 R = randperm(ndata); %1到n这些数随机打乱得到的一个随机数字序列 ...