puporwindow
//Java代码
private void showPopupWindow(View view) { // 一个自定义的布局,作为显示的内容
View contentView = LayoutInflater.from(getActivity()).inflate(
R.layout.layout_popwindow1, null); final PopupWindow popupWindow = new PopupWindow(contentView,
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); popupWindow.setTouchable(true);
popupWindow.setAnimationStyle(R.style.AnimationPreview); popupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override
public boolean onTouch(View v, MotionEvent event) { Log.i("mengdd", "onTouch : "); return false;
// 这里如果返回true的话,touch事件将被拦截
// 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss
}
}); // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
// 我觉得这里是API的一个bug
popupWindow.setBackgroundDrawable(getResources().getDrawable(
R.drawable.whitebg)); // 设置好参数之后再show
//显示popupWindow在界面的位置
popupWindow.showAtLocation(MusicPlayer_Fragment.this.root, Gravity.BOTTOM| Gravity.CENTER_HORIZONTAL, 0, 0);
} //Sytle样式
style name="AnimationPreview" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/pop_enter_anim</item>
<item name="android:windowExitAnimation">@anim/pop_exit_anim</item>
</style>
//在anim下建立动画
名字为:pop_enter_anim.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate
android:duration="200"
android:fromYDelta="100%p"
android:toYDelta="0" />
<alpha
android:duration="200"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set> //名字为
pop_exit_anim
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromYDelta="0"
android:toYDelta="50%p" />
<alpha
android:duration="200"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
puporwindow的更多相关文章
随机推荐
- HashMap和Hashtable的区别 源码分析
一:以前只知道HashMap和HashTable区别,死记硬背的记住HashMap 允许key value为空 而Hashtable 不允许为空 HashMap线程是非线程安全的,而Hashtable ...
- How Google TestsSoftware - Part Five
Instead of distinguishingbetween code, integration and system testing, Google uses the language ofsm ...
- 设置Form窗体中的控件的属性
借助于反射,可获取当前窗体中的所有控件,根据需要设置它们的属性. Font defaultFont = new System.Drawing.Font("Microsoft Sans Ser ...
- sys.dm_db_wait_stats
sys.dm_db_wait_stats 返回在操作期间执行的线程所遇到的所有等待的相关信息. 可以使用此聚合视图来诊断 Azure SQL Database 以及特定查询和批处理的性能问题. 执行查 ...
- 最近修改的几个小bug
最近修改的几个 bug,问题不大,查找起来却几番周折,汇总起来如下. 1.诡异电话号码 客服邮件反馈,很多用户服务热线变成了“0371-45875487”.看到这问题的第一反映是可能因为程序某个地方有 ...
- Oracle循环语句
PL/SQL有四种类型的循环:简单循环.WHILE循环.FOR循环以及游标FOR循环.在这里我们主要讨论前三种,除此之外,还将讨论Oracle 11g中新引入的CONTINUE语句. 一. 简单循环 ...
- PL/SQL Developer中文版下载以及使用图解(绿色版)
下载地址:http://pan.baidu.com/s/1eQCTmkM 1.运行plsqldev.exe程序: 2.设置Oracle主目录名/OCI库地址,如图: 重新启动程序. 3.配置登陆信息, ...
- 转载--linux filesystem structures
In this article, let us review the Linux filesystem structures and understand the meaning of individ ...
- Spring集成MyBatis完整示例
该文详细的通过Spring IOC.MyBatis.Servlet.Maven及Spring整合MyBatis的等技术完成一个简单的图书管理功能,实现图书列表.删除.多删除.编辑.新增功能.梳理前面学 ...
- 在<a></a>标签中调用javascript脚本
有时候,我们点击了<a></a>标签(除了跳转到指定链接外)想要它调用某个方法,及调用javascript脚本,该如何做: 方法1:<a href="javas ...