Skip to content

简化dialog创建,支持滑动关闭,支持嵌套滑动

License

Notifications You must be signed in to change notification settings

goweii/AnyDialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 22, 2020
53f1e2c · Jan 22, 2020

History

47 Commits
Jan 22, 2020
Jan 22, 2020
Dec 24, 2019
Oct 23, 2018
Mar 15, 2019
May 20, 2018
Dec 25, 2019
Dec 25, 2019
Dec 25, 2019
May 20, 2018
May 20, 2018
Feb 15, 2019

Repository files navigation

AnyDialog 使用说明

简化dialog创建,内置5个默认样式,力求还原Android系统动画效果

GitHub主页

Demo下载

简介

  • 链式调用
  • 可自定义数据绑定
  • 可自定义进出场动画

使用说明

集成

  • 添加jitpack库

// build.gradle(Project:)
allprojects {
    repositories {
        ...
            maven { url 'https://www.jitpack.io' }
    }
}
  • 添加依赖

    点击查看最新版本号

    从3.0.3版本开始,版本号前不加v,引用时需要注意。

    从4.0.0版本开始,重构到androidx+kotlin,精简功能,移除背景图和高斯模糊效果。

// build.gradle(Module:)
dependencies {
    implementation 'com.github.goweii:AnyDialog:4.0.0'
}

新建布局

在布局文件根节点设置layout_width,layout_height,layout_margin等属性控制dialog的显示大小

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:cardBackgroundColor="#fff"
    app:cardCornerRadius="12dp"
    app:cardElevation="0dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="@string/app_name"
            android:textColor="#232323"
            android:textSize="17sp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="15dp"
            android:text="@string/dialog_msg"
            android:textColor="#232323"
            android:textSize="15sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#f5f5f5" />

        <TextView
            android:id="@+id/tv_close"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="关闭"
            android:textColor="@color/colorPrimary"
            android:textSize="15sp" />

    </LinearLayout>

</androidx.cardview.widget.CardView>

在代码中调用

 AnyDialog(this).apply {
     style(AnyDialog.Style.CENTER)
     contentView(R.layout.dialog_def)
     clickDismiss(R.id.tv_close)
 }.show()

About

简化dialog创建,支持滑动关闭,支持嵌套滑动

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages