All Projects → CodingEnding → Popuplayout

CodingEnding / Popuplayout

Licence: apache-2.0
通用弹出布局辅助库,允许开发者从顶部、底部、左侧、右侧和中心这五个位置弹出自己指定的View。The general pop-up Layout Assistant library allows developers to show their own view from the top, bottom, left, right and center five locations.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Popuplayout

Stack Up.js
Create fixed width, variable height grid layouts.
Stars: ✭ 117 (-13.33%)
Mutual labels:  layout
Xray React
React layout debugger.
Stars: ✭ 128 (-5.19%)
Mutual labels:  layout
Autoresponsive Vue
Auto responsive grid layout library for Vue.
Stars: ✭ 132 (-2.22%)
Mutual labels:  layout
Flutter Animations
Flutter animation tutorials, such common animation, flare animation.
Stars: ✭ 119 (-11.85%)
Mutual labels:  layout
Spop
A lightweight small pop up widget with no dependencies, create notifications easily with this javascript plugin.
Stars: ✭ 124 (-8.15%)
Mutual labels:  popup
Involt
Inject hardware interactions directly into HTML layout.
Stars: ✭ 128 (-5.19%)
Mutual labels:  layout
Flexlib
FlexLib是一个基于flexbox模型,使用xml文件进行界面布局的框架,融合了web快速布局的能力,让iOS界面开发像写网页一样简单快速
Stars: ✭ 1,569 (+1062.22%)
Mutual labels:  layout
Framezilla
Elegant library that wraps working with frames with a nice chaining syntax.
Stars: ✭ 134 (-0.74%)
Mutual labels:  layout
Kcustomalert
Simple and easy alerts to use instead of default AlertController. Separate Xib is provided to customize as pr your need. Callbacks are easily handled by using Closures.
Stars: ✭ 128 (-5.19%)
Mutual labels:  popup
Widgetlayout
自定义ViewGroup的集合(有 kotlin 实现分支):提高编写效率和 UI 绘制性能,少嵌套,易用易扩展。
Stars: ✭ 130 (-3.7%)
Mutual labels:  layout
Next Layout
Add persistent and nested layouts to your Next.js projects in a declarative way
Stars: ✭ 120 (-11.11%)
Mutual labels:  layout
Greedo Layout For Android
Full aspect ratio grid LayoutManager for Android's RecyclerView
Stars: ✭ 1,588 (+1076.3%)
Mutual labels:  layout
Svelte Simple Modal
A simple, small, and content-agnostic modal for Svelte v3
Stars: ✭ 130 (-3.7%)
Mutual labels:  popup
React Page Layout
Create layouts for react
Stars: ✭ 117 (-13.33%)
Mutual labels:  layout
Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (+1131.11%)
Mutual labels:  layout
Zoid
Cross domain components
Stars: ✭ 1,672 (+1138.52%)
Mutual labels:  popup
Vim Clap
👏 Modern performant fuzzy picker for Vim and NeoVim
Stars: ✭ 1,802 (+1234.81%)
Mutual labels:  popup
Motionlayoutsamples
A sample to take you to appreciate the charm of MotionLayout.
Stars: ✭ 135 (+0%)
Mutual labels:  layout
Pinlayout
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Stars: ✭ 1,870 (+1285.19%)
Mutual labels:  layout
Popo
PoPo is the grid layout tool, the best choice for runtime layout.
Stars: ✭ 130 (-3.7%)
Mutual labels:  layout

PopupLayout

License MinSdk

PopupLayout是通用弹出布局辅助库,允许开发者从顶部、底部、左侧、右侧和中心这五个位置弹出自己指定的View,此外还提供圆角和动画特性。

效果预览

image

Gradle

//根项目下的build.gradle
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

//主项目下的build.gradle
dependencies {
    implementation 'com.github.CodingEnding:PopupLayout:v1.0'
}

Usage

基本使用

PopLayout的使用非常简单,只需要执行以下两步:

1.初始化PopupLayout

通过调用静态方法init初始化PopupLayout。这个方法有两个参数:第一个参数是Context对象,第二个参数代表弹出布局的内容,可以将layout资源Id或者View对象作为参数传入,如下所示:

//1.使用layout资源Id作为弹出布局的内容
PopupLayout popupLayout=PopupLayout.init(MainActivity.this, R.layout.layout_left);

//2.使用View作为弹出布局的内容
View view=View.inflate(MainActivity.this,R.layout.layout_bottom_menu,null);
PopupLayout popupLayout=PopupLayout.init(MainActivity.this,view);

2.在指定位置显示弹出布局

PopupLayout可以从屏幕顶部、底部、左侧、右侧和中心弹出(默认从底部弹出),如下所示:

//从左侧弹出
popupLayout.show(PopupLayout.POSITION_LEFT);
//默认从底部弹出
popupLayout.show();

position的可选值:

  • POSITION_LEFT
  • POSITION_RIGHT
  • POSITION_CENTER
  • POSITION_TOP
  • POSITION_BOTTOM

关闭弹出布局

点击弹出布局之外的区域,PopupLayout会被自动关闭。当然,也可以通过调用dismiss或hide方法手动关闭。这两个方法的区别在于hide只是隐藏弹出布局,并不会释放资源;而dismiss会销毁弹出布局并释放资源。通常情况下,建议使用dismiss方法。

public void dismiss()
public void hide()

注意:在Activity退出时必须使用dismiss方法销毁弹出布局,释放资源。

限制弹出布局的大小

默认情况下,PopupLayout会根据不同的弹出位置自动适配弹出布局的大小。具体而言,如果从顶部/底部弹出,宽度为MATCH_PARENT,高度为WRAP_CONTENT;如果从左侧/右侧弹出,宽度为WRAP_CONTENT,高度为MATCH_PARENT;如果从中心弹出,宽度为WRAP_CONTENT,高度为WRAP_CONTENT。

当然,PopupLayout也提供了setHeight和setWidth两个方法用于手动设置弹出布局的大小。这两个方法原型如下:

/**
 * 设置弹出布局的高度
 * @param height 高度
 * @param dpMode 是否以dp为单位
 */
public void setHeight(int height,boolean dpMode)

/**
 * 设置弹出布局的宽度
 * @param width 宽度
 * @param dpMode 是否以dp为单位
 */
public void setWidth(int width,boolean dpMode)

注意:这两个方法必须要在调用show方法之前使用才有效。

相关方法

方法名 返回值 说明
static init(Context context,@LayoutRes int contentLayoutId) PopupLayout 初始化弹出布局
static init(Context context,View contentView) PopupLayout 初始化弹出布局
show(int position) void 从指定位置显示弹出布局
show() void 默认从底部显示弹出布局
dismiss() void 隐藏弹出布局(同时会销毁弹出布局,释放资源),建议使用
hide() void 隐藏弹出布局(不会销毁弹出布局),不会触发DismissListener
setUseRadius(boolean useRadius) void 是否使用圆角特性(默认使用)
setHeight(int height,boolean dpMode) void 设置弹出布局的高度
setWidth(int width,boolean dpMode) void 设置弹出布局的宽度
setDismissListener(DismissListener dismissListener) void 设置Dismiss监听器(在弹出布局消失时触发)

监听器

PopupLayout允许使用者监听弹出布局的消失事件,只需要为PopupLayout设置DismissListener即可,如下所示:

PopupLayout popupLayout=PopupLayout.init(MainActivity.this, R.layout.layout_bottom);
popupLayout.setDismissListener(new PopupLayout.DismissListener() {
    @Override
    public void onDismiss() {
        Toast.makeText(MainActivity.this,"弹出窗口关闭",Toast.LENGTH_SHORT).show();
    }
});//添加监听器

Blog

欢迎访问我的博客:

https://blog.csdn.net/codingending

License

Copyright CodingEnding

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].