android-overlaydialog

A customizable dialog shown on top of the window

License

License

MIT
GroupId

GroupId

com.github.fernandospr
ArtifactId

ArtifactId

overlaydialog
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

aar
Description

Description

android-overlaydialog
A customizable dialog shown on top of the window
Project URL

Project URL

https://github.com/fernandospr/android-overlay-dialog
Source Code Management

Source Code Management

https://github.com/fernandospr/android-overlay-dialog

Download overlaydialog

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.fernandospr/overlaydialog/ -->
<dependency>
    <groupId>com.github.fernandospr</groupId>
    <artifactId>overlaydialog</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.fernandospr/overlaydialog/
implementation 'com.github.fernandospr:overlaydialog:1.0.1'
// https://jarcasting.com/artifacts/com.github.fernandospr/overlaydialog/
implementation ("com.github.fernandospr:overlaydialog:1.0.1")
'com.github.fernandospr:overlaydialog:aar:1.0.1'
<dependency org="com.github.fernandospr" name="overlaydialog" rev="1.0.1">
  <artifact name="overlaydialog" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.fernandospr', module='overlaydialog', version='1.0.1')
)
libraryDependencies += "com.github.fernandospr" % "overlaydialog" % "1.0.1"
[com.github.fernandospr/overlaydialog "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

android-overlay-dialog

A customizable dialog shown on top of the window. Useful for showing info/error messages.

Sample app

How to use

Please, add the following dependency to your gradle file:

compile 'com.github.fernandospr:overlaydialog:1.0.1'

OverlayDialog inherits from android.app.Dialog, so you can use the same methods from Dialog, for example:

OverlayDialog dialog = new OverlayDialog(this);
dialog.setCancelable(true);
...
dialog.show();
...
dialog.dismiss();

To customize the view for the dialog, you should use:

View customView = LayoutInflater.from(this).inflate(layoutResID, root, false);
...
dialog.setContentView(customView);

To customize the auto dismiss time, you should use:

dialog.setAutoDismissDelayMillis(5000);

To customize the enter/exit animations, you should create a theme and set it in the constructor, for example:

OverlayDialog dialog = new OverlayDialog(this, R.style.TopMessageDialog);
  • res/values/styles.xml
<style name="TopMessageDialog" parent="Theme.AppCompat.Dialog">
    <item name="android:windowAnimationStyle">@style/TopMessageDialogAnimation</item>
</style>

<style name="TopMessageDialogAnimation">
    <item name="android:windowEnterAnimation">@anim/translate_from_top</item>
    <item name="android:windowExitAnimation">@anim/translate_to_top</item>
</style>
  • res/anim/translate_from_top.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="600">
    <translate
        android:fromYDelta="-100%"
        android:toYDelta="0%" />
    <alpha
        android:fromAlpha="0"
        android:toAlpha="1" />
</set>
  • res/anim/translate_to_top.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="600">
    <translate
        android:fromYDelta="0%"
        android:toYDelta="-100%" />
    <alpha
        android:fromAlpha="1"
        android:toAlpha="0" />
</set>

See the sample app for more examples.

Versions

Version
1.0.1
1.0.0