popupWindow的使用心得
本来项目中用到popupWindow,后来需求改了,大家懂得~,但是不能白研究了,写点心得,以备日后查看---------------------------
首先,要为popupWindow 写一个xml配置文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_max"
android:layout_marginRight="@dimen/margin_max"
android:background="@color/white"
android:orientation="vertical" >
<!-- main content -->
<TextView
android:id="@+id/diet_pop_tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_max"
android:text="@string/activity_aerobic"
android:textColor="@color/string_bgwhite_main"
android:textSize="@dimen/text_15" />
<!-- main content sub -->
<TextView
android:id="@+id/diet_pop_tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/recipe_choose_exam"
android:layout_marginLeft="@dimen/margin_max"
android:textColor="@color/string_bgwhite_sub"
android:textSize="@dimen/text_15" />
<!-- second title -->
<TextView
android:id="@+id/diet_pop_tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/diet_pop_title"
android:paddingLeft="@dimen/margin_max"
android:layout_marginLeft="@dimen/margin_max"
android:text="@string/activity_aerobic_content"
android:textColor="@color/white"
android:textSize="@dimen/text_15"
/>
<!-- second content -->
<TextView
android:id="@+id/diet_pop_tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_max"
android:text="@string/activity_aerobic_suggest"
android:textColor="@color/string_bgwhite_main"
android:textSize="@dimen/text_15" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:background="@drawable/popupshadow"
/>
</LinearLayout>
</LinearLayout>
---------然后---再代码中处理popupWindow,
// new popupwindow
View inflateView = getLayoutInflater().inflate(
R.layout.recipe_popwindow, null);//上面的xml文件,作为popupWindow的视图
mPopupWindow = new PopupWindow(inflateView, LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
mPopupWindow.setFocusable(false);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setAnimationStyle(R.style.AnimationPreview);//为popupWindow设置进入,退出的动画效果
------下面配置进入退出的动画:
anim文件夹下,进入动画(由右下角进入,由小变大):
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale=".1" android:toXScale="1.0"
android:fromYScale=".1" android:toYScale="1.0"
android:pivotX="100%p" android:pivotY="100%p"
android:duration="500"/>
<alpha android:fromAlpha="0" android:toAlpha="1.0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
退出动画(向右下角退出,由大变小,变透明):
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="100%p" android:pivotY="100%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
--------在styles文件夹下配置style:
<style name="AnimationPreview">
<item name="android:windowEnterAnimation">@anim/zoomin</item>
<item name="android:windowExitAnimation">@anim/zoomout</item>
</style>
-------最后在代码中设置popupWindow进入退出的判定:
public void openMenu(View v) {
// System.out.println(view.getId() + "-----id--" + view.getBottom()
// + "bottom-----view" + view.getTop());
if (!flag) {//flag初始化为false;
// set position
// mPopupWindow.showAtLocation(view, Gravity.LEFT, 0, 0);
mPopupWindow.showAsDropDown(v, 0, 0);
// view.findViewById(R.id.diet_sugget_ka).setVisibility(View.INVISIBLE);
flag = true;
} else {
mPopupWindow.dismiss();
flag = false;
}
}
------------------------------binggou,完成了。
popupWindow的使用心得相关推荐
- Java EE学习心得
–Java EE学习心得 1. 称为编程专家的秘诀是: 思考-----编程--------思考------编程--.. 编程不能一步到位,不能一上来就编,必须先思考如何写,怎样写?然后再编程 ...
- 测试心得:微图书销售小程序
测试心得:微图书销售小程序 前言 这个学期差不多也将近结束,经过大半个学期,从项目需求的确认和项目文档的编写,到一步步的设计与实现,现在终于到了测试阶段,但是我们在测试阶段也暴露出了很多bug,但是每 ...
- java.lang.OutOfMemoryError:GC overhead limit exceeded填坑心得
该文章出自:http://www.cnblogs.com/hucn/p/3572384.html 分析工具:http://www.blogjava.net/jjshcc/archive/2014/03 ...
- android 封装的popwindow,Android UI开发 popupwindow介绍以及代码实例
PopupWindow在android.widget包下,弹出窗口的形式展示.官方文档对该控件的描述是:"一个弹出窗口控件,可以用来显示任意视图(View),而且会浮动在当前 活动(acti ...
- android window 大小,android popupWindow 中宽度莫名很大,求帮助?
这个是popupwindow的内容xml(就是放了个ListView): android:layout_width="wrap_content" android:layout_he ...
- 计算机财务应用实验心得,计算机会计实习心得-20210628124643.doc-原创力文档
计算机会计实习心得 计算机会计实习心得1 毕业实践环节是大学生在完成全部课程后.走向社会之前最真实的一个模拟实验,对于我们财会专业的学生,平时注意注重理论学习,缺乏实践锻炼,因此实习显得尤为重要.在本 ...
- html5考试总结300字,期中考心得300字5
为了检验学生半个学期所学的知识而进行的一次考试,有利于学生比较正式地检验自己平时的学习水平,根据这个成绩,学生可以及时的调整学习心态和方法,更有效率地进行下一阶段的学习,期中考试主要考察学生前半学期的 ...
- Assembly学习心得
http://blog.csdn.net/etmonitor/ Assembly学习心得 说明: 最近开始准备把学到的.NET知识重新整理一遍,眼过千遍不如手过一遍,所以我准备记下我的学习心得,已备参 ...
- 什么叫安装文件索引服务器,搜出精彩 玩转Windows 2008系统心得
[IT168 专稿]不少朋友已经在不经意间与Windows Server 2008系统进行了亲密接触,在一段时间的接触之后,不知大家对该系统的文件搜索功能会有什么样的体会?其实,Windows Ser ...
最新文章
- vPower系列- 前言
- js-innerHTML
- 大数据WEB阶段 TransientDateAccessResourceException
- 【C】Natasha V1.3.6.0 的升级日志
- Hadoop伪分布式配置和搭建,hadoop单机安装,wordcount实例测试,hadoop安装java目录怎么找,问题及问题解决方法
- Python操作MySQL的封装类
- mysql 5.6 利用gtid 同步数据遇到的问题记录
- 自定义php报错信息,自定义PHP的错误报告处理方式
- JavaScript学习之ES6学习之Promise
- js获取当前页面的地址和端口_url
- 出现Field 'ssl_cipher' doesn't have a default value错误怎么解决
- 图像增强--视网膜皮层Retinex算法(二)
- 无根树的计数——prufer序列
- “二十一天好习惯”第一期-20
- Android常用库和插件避免重复造轮子(持续更新)
- pwm调速c语言,PWM调速的C语言程序编写
- 数据挖掘::实验一 WEKA分类
- UE4 蓝图学习 FlipFlop
- PHP返回凌晨好早晨好中午好下午好等
- 常用控件 — 列表视图
热门文章
- java 6789的10000次方,用MSSQL计算2的10000次方
- java电池soc算法实现,BMS算法设计之电池SOC介绍(一)
- 今日问题:开发在临近发布时“画蛇添足”,测试没有时间测试,该如何处理?
- 判断一个整数的奇偶性php,【算法】- 判断一个整数是否是奇数
- 什么是 Service Mesh?
- Python接口测试
- 软件测试,何去何从?想安逸不可能!软饭得硬吃...我整理的超全学习指南【值得每个测试一看】
- 性能测试:记一次生产环境性能测试优化实践
- android excel 筛选功能,Android 实现 Excel 解析 xls 和 xlsx,方法也可以很简单
- BP神经网络matlab程序运行问题