Convert Figma logo to code with AI

razerdp logoBasePopup

Android下打造通用便捷的PopupWindow弹窗库

5,187
754
5,187
28

Top Related Projects

An android library to make swipe more easier and more powerful. Android各种侧滑,有这一个就够了

7,705

🔥XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!(Powerful and Beautiful Popup for Android,can absolutely replace Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner. With built-in animators , very easy to custom popup view.)

Andorid 任意界面悬浮窗,实现悬浮窗如此简单

:fire: Android developers should collect the following utils(updating).

12,861

🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。

Quick Overview

BasePopup is a powerful and flexible Android popup window library. It simplifies the process of creating and managing custom popup windows, offering a wide range of customization options and built-in animations.

Pros

  • Easy to use with a fluent API design
  • Highly customizable with numerous built-in features
  • Supports various animation effects out of the box
  • Actively maintained with regular updates and bug fixes

Cons

  • May have a slight learning curve for complex customizations
  • Some advanced features might require additional setup
  • Documentation could be more comprehensive for certain use cases

Code Examples

Creating a simple popup:

new ABasePopupView(context)
    .setContent(R.layout.popup_content)
    .setAnimationStyle(PopupAnimationStyle.ScaleAlphaFromCenter)
    .showPopupWindow();

Customizing popup position:

new ABasePopupView(context)
    .setContent(R.layout.popup_content)
    .setPopupGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL)
    .showPopupWindow();

Adding a click listener to dismiss the popup:

new ABasePopupView(context)
    .setContent(R.layout.popup_content)
    .setOnClickListener(v -> dismiss())
    .showPopupWindow();

Getting Started

  1. Add the dependency to your build.gradle file:
dependencies {
    implementation 'io.github.razerdp:BasePopup:3.2.1'
}
  1. Create a new popup class extending BasePopupWindow:
public class MyPopup extends BasePopupWindow {
    public MyPopup(Context context) {
        super(context);
        setContentView(R.layout.my_popup_layout);
    }
}
  1. Use the popup in your activity or fragment:
MyPopup popup = new MyPopup(this);
popup.showPopupWindow();

Competitor Comparisons

An android library to make swipe more easier and more powerful. Android各种侧滑,有这一个就够了

Pros of SmartSwipe

  • Focuses on swipe gestures and interactions, providing more specialized functionality for swipe-based UIs
  • Offers a wider range of swipe directions and customization options
  • Includes built-in support for common swipe patterns like drawer, parallax, and stack effects

Cons of SmartSwipe

  • Less versatile for general popup and dialog implementations
  • May have a steeper learning curve due to its more specialized nature
  • Potentially less suitable for projects that don't heavily rely on swipe gestures

Code Comparison

BasePopup example:

QuickPopupBuilder.with(context)
    .contentView(R.layout.popup_content)
    .config(new QuickPopupConfig()
        .gravity(Gravity.CENTER)
        .withClick(R.id.btn_close, null))
    .show();

SmartSwipe example:

SmartSwipe.wrap(view)
    .addConsumer(new SlidingConsumer())
        .setScrimColor(0x7F000000)
        .setRelativeMoveFactor(0.5f)
        .setEdgeSize(300)
        .setReturnDuration(300)
        .enableEdgeLeft()
        .enableEdgeRight();

While BasePopup focuses on creating and managing popup windows with various configurations, SmartSwipe specializes in adding swipe gestures and interactions to existing views. The code examples demonstrate their different approaches and use cases.

7,705

🔥XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!(Powerful and Beautiful Popup for Android,can absolutely replace Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner. With built-in animators , very easy to custom popup view.)

Pros of XPopup

  • More comprehensive set of built-in popup types and animations
  • Easier customization of popup appearance and behavior
  • Better support for complex layouts and nested popups

Cons of XPopup

  • Larger library size, potentially impacting app performance
  • Steeper learning curve due to more features and options
  • Less frequent updates and maintenance compared to BasePopup

Code Comparison

BasePopup basic usage:

new BasePopupWindow(context)
    .setContent(R.layout.popup_content)
    .setWidth(LayoutParams.MATCH_PARENT)
    .setHeight(LayoutParams.WRAP_CONTENT)
    .showPopupWindow();

XPopup basic usage:

new XPopup.Builder(context)
    .asCustom(new CustomPopup(context))
    .show();

Both libraries offer simple APIs for creating popups, but XPopup provides more built-in options and customization possibilities out of the box. BasePopup focuses on a lightweight approach, while XPopup offers a more feature-rich experience at the cost of increased complexity and library size.

Andorid 任意界面悬浮窗,实现悬浮窗如此简单

Pros of FloatWindow

  • Specialized for creating floating windows, offering more tailored features for this specific use case
  • Simpler API for creating and managing floating windows
  • Supports system-wide floating windows, even when the app is in the background

Cons of FloatWindow

  • Less flexible for general popup scenarios compared to BasePopup's wider range of popup types
  • Limited customization options for popup animations and styles
  • Smaller community and less frequent updates

Code Comparison

BasePopup:

QuickPopupBuilder.with(context)
    .contentView(R.layout.popup_content)
    .config(new QuickPopupConfig()
        .gravity(Gravity.CENTER)
        .withClick(R.id.btn_close, PopupWindow::dismiss))
    .show();

FloatWindow:

FloatWindow
    .with(getApplicationContext())
    .setView(view)
    .setX(100)
    .setY(100)
    .setDesktopShow(true)
    .build();

BasePopup offers more configuration options in its builder pattern, while FloatWindow provides a simpler API focused on floating window creation and positioning.

:fire: Android developers should collect the following utils(updating).

Pros of AndroidUtilCode

  • Comprehensive collection of utility functions covering a wide range of Android development needs
  • Well-documented with clear examples and usage instructions
  • Regularly updated and maintained with a large community of contributors

Cons of AndroidUtilCode

  • Large library size may impact app performance if not properly optimized
  • Some utilities may be redundant or unnecessary for specific projects
  • Learning curve can be steep due to the extensive range of utilities

Code Comparison

BasePopup:

BasePopupWindow popupWindow = new BasePopupWindow(context);
popupWindow.setContentView(R.layout.popup_layout);
popupWindow.showPopupWindow();

AndroidUtilCode:

ToastUtils.showShort("Hello, World!");
ScreenUtils.getScreenWidth();
TimeUtils.getNowString();

Summary

BasePopup focuses on creating customizable popup windows, while AndroidUtilCode provides a wide range of utility functions for Android development. BasePopup is more specialized and lightweight, whereas AndroidUtilCode offers a comprehensive toolkit at the cost of increased library size. Choose BasePopup for specific popup needs and AndroidUtilCode for general utility functions across various Android development tasks.

12,861

🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。

Pros of banner

  • Specialized for banner/slider functionality, offering a more focused and optimized solution
  • Provides a rich set of customization options for banner displays
  • Includes built-in support for various animation effects and transitions

Cons of banner

  • Limited to banner/slider functionality, less versatile for general popup needs
  • May require additional libraries or custom code for complex popup scenarios
  • Less frequent updates and smaller community compared to BasePopup

Code Comparison

BasePopup example:

QuickPopupBuilder.with(context)
    .contentView(R.layout.popup_content)
    .config(new QuickPopupConfig()
        .blurBackground(true)
        .withShowAnimation(AnimationHelper.asAnimation()
            .withAlpha(0f, 1f)
            .toShow())
    .show();

banner example:

Banner banner = findViewById(R.id.banner);
banner.setAdapter(new BannerImageAdapter<DataBean>(mDatas) {
    @Override
    public void onBindView(BannerImageHolder holder, DataBean data, int position, int size) {
        holder.imageView.setImageResource(data.imageRes);
    }
});

Both libraries offer easy-to-use APIs, but BasePopup provides more general-purpose popup functionality, while banner focuses specifically on banner/slider implementations.

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。

Pros of SmartRefreshLayout

  • More comprehensive and feature-rich for pull-to-refresh functionality
  • Extensive customization options for refresh headers and footers
  • Large community support with frequent updates and contributions

Cons of SmartRefreshLayout

  • Focused solely on refresh layouts, less versatile for other UI components
  • Steeper learning curve due to more complex API and configuration options
  • Potentially higher overhead for simple refresh implementations

Code Comparison

SmartRefreshLayout:

RefreshLayout refreshLayout = findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new ClassicsHeader(this));
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh(RefreshLayout refreshlayout) {
        refreshlayout.finishRefresh(2000/*,false*/);
    }
});

BasePopup:

CustomPopup popup = new CustomPopup(context);
popup.setPopupGravity(Gravity.BOTTOM)
     .setShowAnimation(PopupAnimator.TranslateFromBottom)
     .setDismissAnimation(PopupAnimator.TranslateToBottom)
     .showPopupWindow();

Summary

While SmartRefreshLayout excels in providing advanced pull-to-refresh functionality with extensive customization options, BasePopup offers a more versatile solution for creating various types of popups and dialogs. SmartRefreshLayout is ideal for projects requiring sophisticated refresh layouts, whereas BasePopup is better suited for applications needing flexible popup implementations.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

中文 | English

Logo图片似乎加载不出来

BasePopup - Android下打造通用便捷的PopupWindow弹窗库

Release Snapshot License Api Author



作者的话

由于工作繁忙,且目前issue问题影响并不大,因此本库维护速度较慢。

同时希望大佬们也可以推送自己的PR,我这边review后会进行合并的~

下一次更新大概在24年3月份

介绍

BasePopup是一个对系统PopupWindow进行封装并改进的弹窗库,它是一个基础库类,有着非常高的自由度与丰富的API,您可以在BasePopup的框架下非常轻松的完成各种各样的弹窗。

环境依赖

// root gradle
allprojects {
    repositories {
        // release依赖仓库(4.1后as默认配置有)
        mavenCentral()

        // snapshot仓库(如果需要snapshot依赖,请配置该maven)
        maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
    }
}

// project dependencies
dependencies {
  implementation 'io.github.razerdp:BasePopup:3.2.1'

  // for snapshot
  // implementation 'io.github.razerdp:BasePopup:3.2.1-SNAPSHOT'
}

文档

注意事项

  • Release和Snapshot两个版本互相切换可能会导致Build失败,这时候您Clean一下Project即可
  • 3.0版本会对2.x版本升级上来的用户造成较大范围的改动,请您务必阅读升级提示:关于BasePopup 3.0的破坏性更新说明

更新日志 (历史更新)

  • 【Release】3.2.1 (2022/12/29)
    • 不知不觉,距离上次更新居然已经一年了,不是我弃坑了,实则是工作有点忙
    • 另外作者我现在是在网易撸游戏了(嗯,已经撸了3年了),已经不是一个单纯的安卓程序员了,虽然还有关注并且迭代,但节奏肯定会慢下来不少
    • 不过~我还是会坚持更新的-V-
    • 【优化】
      • 对BlurOption预缩放下限作出限制(如果模糊预缩放小于0,则返回默认值)
      • QuickPopupConfig添加@keep #462
    • 【Bug修复】
      • 修复navigationbar不在DecorView层级下的判断问题(通过WindowInsets二次判断),fixed bug #452

例子预览

更多例子请下载Demo:apk体验下载(密码123)


打赏(您的支持是我持续更新的动力~)

Logo图片似乎加载不出来

License

FOSSA Status

Apache-2.0

Visit Count(from 2020/08/19)