android dialog 自定义按钮样式,android-styled-dialogs

android-styled-dialogs.svg?branch=masterlicense-Apache%202-green.svg?style=flat

9011b2d276a5d6336c1da2f03437bf82.png

Demo app:

get_it_on_play_logo_small.png

Features:

Compatible with Material Design Guidelines

Same look for Android 2.2+

Built on top of standard DialogFragment

Supports stacked buttons, neutral button, callbacks even after rotation

Light and dark theme

Contains even more specialized dialogs: List, Progress, Time&Date Picker, Custom, ...

How to include it in your project:

dependencies {

compile 'com.avast:android-styled-dialogs:2.3.3'

}

Hosted in jcenter: download.svg

How to style all dialogs:

It uses standard Material colors, for example like this:

@color/indigo

@color/indigo_dark

@color/pink

For dark theme, inherit from Theme.AppCompat. Or you can force dark theme per individual dialog using useDarkTheme() builder method.

You can also force light theme per individual dialog using useLightTheme() builder method.

How to create simple dialogs:

Easy:

Dialog with a simple message only:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();

Dialog with a title, message and two buttons:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).setPositiveButtonText(R.string.positive_button).setNegativeButtonText(R.string.negative_button).show();

How to react on button press in your Activity/Fragment:

Simply implement interface ISimpleDialogListener in your Activity/Fragment. Listener's callbacks have requestCode parameter - you can use it if you have more dialogs in one Activity/Fragment.

For Fragments use setTargetFragment() method in the builder.

It's not possible to use normal Java callbacks, because they are lost after device rotation.

How to react on cancelling the dialog:

Implement interface ISimpleDialogCancelListener in your Activity/Fragment.

How to create custom DialogFragments:

Extend BaseDialogFragment.

Have a look at JayneHatDialogFragment for a practical example.

Contributing

Pull requests are welcomed!

Please set your Android Studio formatting to our code style.

Why 'Dialogs'?

34a8110a82c3e1eb62b2b7e3f00cbbc2.png

Theodor Dialogs was a famous Czech painter, uncle of Jára Cimrman. Jára Cimrman was a playwright, philosopher, inventor, teacher, poet, mathematician and more but he lacked painting skills. That's why Theodor was helping him with many projects. Just like Android and this library do.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值