首页 » Andorid » 安卓例子 » 正文

基于相对位置实现弹出 PopupWindow

RelativePopupWindow

wercker status Platform

[![API](https://img.shields.io/badge/API-9%2B-yellow.svg?style=flat)](https://android-arsenal.com/api?level=9) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RelativePopupWindow-green.svg?style=true)](https://android-arsenal.com/details/1/3908)

Android PopupWindow that can be easily located relative to anchor View.

Art

How To Use

Extend RelativePopupWindow class and call showOnAnchor().

popup.showOnAnchor(anchor, VerticalPosition.ABOVE, HorizontalPosition.CENTER);

See detail example in ExampleCardPopup.kt or in Java, ExampleCardPopup.java.

Position Parameters

VerticalPosition

  • ABOVE
  • ALIGN_BOTTOM
  • CENTER
  • ALIGN_TOP
  • BELOW

HorizontalPosition

  • LEFT
  • ALIGN_RIGHT
  • CENTER
  • ALIGN_LEFT
  • RIGHT

Fit In Screen

If you want Popup not to fit in screen automatically, add parameter to disable it.

popup.showOnAnchor(anchor, VerticalPosition.ABOVE, HorizontalPosition.CENTER, false);

Install

This library is available in jcenter.

compile 'com.labo.kaji:relativepopupwindow:0.3.1'

License

MIT License.

下载 (1)

发表评论