PopupWindow example


LinearLayout layout = (LinearLayout) getLayoutInflater()
						.inflate(R.layout.popwindow, null);
				/**
				 * <p>
				 * Create a new popup window which can display the
				 * <tt>contentView</tt>. The dimension of the window must be
				 * passed to this constructor.
				 * </p>
				 * 
				LinearLayout layout = (LinearLayout) getLayoutInflater()
						.inflate(R.layout.popwindow, null);
				/**
				 * <p>
				 * Create a new popup window which can display the
				 * <tt>conten
				 * <p>
				 * The popup does not provide any background. This should be
				 * handled by the content view.
				 * </p>
				 * 
				 * @param contentView
				 *            the popup's content
				 * @param width
				 *            the popup's width
				 * @param height
				 *            the popup's height
				 * @param focusable
				 *            true if the popup can be focused, false otherwise
				 */
				final PopupWindow popupWindow = new PopupWindow(layout, 200, 200,
						true);
				  /**
			     * <p>Change the animation style resource for this popup.</p>
			     *
			     * <p>If the popup is showing, calling this method will take effect only
			     * the next time the popup is shown or through a manual call to one of
			     * the {@link #update()} methods.</p>
			     *
			     * @param animationStyle animation style to use when the popup appears
			     *      and disappears.  Set to -1 for the default animation, 0 for no
			     *      animation, or a resource identifier for an explicit animation.
			     *      
			     * @see #update()
			     */
				popupWindow.setAnimationStyle(R.style.PopupAnimation2);
				 /**
			     * <p>Display the content view in a popup window anchored to the bottom-left
			     * corner of the anchor view offset by the specified x and y coordinates.
			     * If there is not enough room on screen to show
			     * the popup in its entirety, this method tries to find a parent scroll
			     * view to scroll. If no parent scroll view can be scrolled, the bottom-left
			     * corner of the popup is pinned at the top left corner of the anchor view.</p>
			     * <p>If the view later scrolls to move <code>anchor</code> to a different
			     * location, the popup will be moved correspondingly.</p>
			     *
			     * @param anchor the view on which to pin the popup window
			     *
			     * @see #dismiss()
			     */
				popupWindow.showAsDropDown(button, 100, 150);
				
				layout.findViewById(R.id.dismissPopupWindow).setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View v) {
						
						popupWindow.dismiss();
						
						
					}
				});
				

			}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值