Android中Popuwindown的使用(我的项目中扣出的代码)

来源:互联网 发布:mastercam9.1编程视频 编辑:程序博客网 时间:2024/05/19 01:28
<pre name="code" class="html">
if (popupwindow != null&&popupwindow.isShowing()) {popupwindow.dismiss();return;} else {initmPopupWindowView();// popupwindow.showAsDropDown(view, 0, 5);popupwindow.showAsDropDown(view, 0, PARAM.Dp2Px(context, 5));}
<span style="font-family: Arial, Helvetica, sans-serif;">public void initmPopupWindowView() {</span>
// // 获取自定义布局文件pop.xml的视图View customView = getLayoutInflater().inflate(R.layout.mystock_detail_popup_window_2,null, false);// 创建PopupWindow实例,200,150分别是宽度和高度//popupwindow = new PopupWindow(customView, 300, 360);//180,200popupwindow = new PopupWindow(customView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);// 设置动画效果 [R.style.AnimationFade 是自己事先定义好的]popupwindow.setAnimationStyle(R.style.AnimationFade);//popupwindow.setOutsideTouchable(true);// 自定义view添加触摸事件customView.setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {if (popupwindow != null && popupwindow.isShowing()) {popupwindow.dismiss();popupwindow = null;}return false;}});img_delet = (ImageView) customView.findViewById(R.id.img_delet);img_share = (ImageView) customView.findViewById(R.id.img_share);img_delet.setOnClickListener(this);img_share.setOnClickListener(this);}

 <style name="AnimationFade">        <!-- PopupWindow左右弹出的效果 -->        <item name="android:windowEnterAnimation">@anim/inuptodown</item>        <item name="android:windowExitAnimation">@anim/outdowntoup</item>    </style>


inputodown.xml<?xml version="1.0" encoding="UTF-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" >    <translate        android:duration="500"        android:fromYDelta="-100%"        android:toYDelta="0" /></set>


outdowntoup.xml<?xml version="1.0" encoding="UTF-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" >    <translate        android:duration="500"        android:fromYDelta="0"        android:toYDelta="-100%" /></set>




0 0
原创粉丝点击