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

<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,200
		popupwindow = 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() {
			@Override
			public 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值