javiersantos / materialstyleddialogs Goto Github PK
View Code? Open in Web Editor NEWA library that shows a beautiful and customizable Material-based dialog with header. API 14+ required.
License: Apache License 2.0
A library that shows a beautiful and customizable Material-based dialog with header. API 14+ required.
License: Apache License 2.0
I was working on converting a project to use your very nice dialogs, the problem I have is that they are largely compatible concept wise to calling AlertDialog.Builder, but all the names and types change, making it very time consuming to change to using it. Unfortunately I also just noticed you made many breaking changes so this suggestion probably comes too late.
It would be very nice if you used the same names and types as the AlertDialog Builder to help with conversion to using your library.
Hello,
the below method was not work,how to add a dismiss listener?
dialog.setOnDismissListener();
My application uses either a light or dark theme, the dialogs don't follow that theme, could you follow the theming in the supplied context instead of your own? It especially becomes an issue when using custom views as there is no access to the context you provide.
Another issue is that it would be nice to be able to supply a tint for the icon, mine are dark as they are easier to work with, but I have to manually tint them for all dialogs.
Hi,
Adding this line
compile 'com.github.javiersantos:MaterialStyledDialogs:1.2.1'
to gradle file, results
Failed to resolve: com.github.javiersantos:MaterialStyledDialogs:1.2.1
The icon will cut to half sometimes, I am using this code
public static void infoDialogue(Context context, String info) {
final MaterialStyledDialog.Builder dialogHeader_1 = new MaterialStyledDialog.Builder(context)
.setStyle(Style.HEADER_WITH_ICON)
.setIcon(new IconicsDrawable(context).icon(MaterialDesignIconic.Icon.gmi_info).color(Color.WHITE))
.withIconAnimation(false)
.setTitle("Info")
.setDescription(info)
.setHeaderColor(R.color.yellow)
.setNegativeText("OK");
dialogHeader_1.show();
}
Can anyone help with this?
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View Customview = inflater.inflate(R.layout.vh_othersizes,null);
RecyclerView rvOtheritems = (RecyclerView) Customview.findViewById(R.id.rvOtherSizes);
OtherSizesAdaptor osa = new OtherSizesAdaptor(allItems, getActivity());
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setOrientation(LinearLayoutManager.VERTICAL);
rvOtheritems.setLayoutManager(llm);
rvOtheritems.setAdapter(osa);
new MaterialStyledDialog(getActivity())
.setTitle("Other Sizes")
.setCancelable(true)
.setIcon(R.drawable.ic_movestock)
.withIconAnimation(true)
.setHeaderColor(R.color.buttonBlue)
.setCancelable(true)
.setCustomView(Customview)
.build().show();
});
No errors, the dialog box displays but the RecyclerView doesnt?
Using vector drawable with setIcon(...
) crashes the app on older devices than the lollipop. Looks like library needs to use AppCompatImageView
withapp:srcCompat
attribute now instead of older ImageView
with android:src
.
There are some wrong code in slide up animation related xml files. This causes wrong behaviour. If you watch carefully slide up animations you will see.
Currently: md_styled_slide_up_fast.xml :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromYDelta="100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0" />
</set>
But it must be like this :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromYDelta="100%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="0%p"/>
</set>
Those small mistakes are in slide up animation related xml files.(all three)
Nothing big, it is just a small mistake.
Thanks for the library.
Please allow setHeaderColor to also accept a real color so that dynamic colors can be assigned at runtime.
com.github.afollestad.material-dialogs/core/0.8.5.4/res/values-v11/values-v11.xml/Users/Jorge1Old/AndroidStudioProjects/My_Andorra_Telecom/app/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.4/res/values-v11/values-v11.xml
Error:(3, 5) No resource found that matches the given name (at 'android:actionModeCloseDrawable' with value '@drawable/abc_ic_ab_back_mtrl_am_alpha').
See the title, I want to make the CustomView width a little bit wider, so It will fit. How can I do this?
I am stuck to set Button color e.g i want to make black positive and red negative button.
I would like to use 2 colors (HeaderColor = primary color & [Text , Button] = white color).
new MaterialStyledDialog(CargoPlaceActivity.this)
// .setTitle("Logout!")
.setDescription("Are you sure, you want to logout ?")
.setIcon(R.drawable.splash)
.withDialogAnimation(true, Duration.SLOW)
.setCancelable(false)
.setPositive(getResources().getString(R.string.positive_button), new MaterialDialog.SingleButtonCallback() {
@OverRide
public void onClick(MaterialDialog dialog, DialogAction which) {
//
}
})
.setNegative(getResources().getString(R.string.negative_button), new MaterialDialog.SingleButtonCallback() {
@OverRide
public void onClick(MaterialDialog dialog, DialogAction which) {
//
}
})
.show();
In the first build of Material Styled Dialogs, the icon animation would play every time the dialogue appears. Now, the icon animation only plays the first time the dialogue appears.
EDIT: I've looked a bit further and the cause appears to be update v1.1.1
In that update, the dialogue is not rebuilt everytime show() is called which means the animation would not play again. Is there a way around this?
The method isShowing() of the class MaterialStyledDialog always return false
When we use calligraphy to set specific font to our activity , header and description of MaterialStyledDialog changes fonts , but button font do not change to that font!
Hello,
is it possible to use icons in the dialog footer? i.e. for positive and negative buttons?
Maybe add this to let the user know that this is the old standard, In case people want it
//Old standard padding: .setCustomView(your_custom_view, 20, 20, 20, 0)
Is it possible to use my own custom layout on the material dialog? if so, how can i do it?
Hi,
I tried adding the library and repository to my build.gradle without problem. I didn't implement the dialog box code yet.. The problem is, when I click my login button, it shows this error :
Could not find a method submit(View)
...
Caused by: java.lang.NoSuchMethodException: submit [class android.view.View]
The error gone when I remove the library and repository.
Can anyone help me why is this happened?
Thank you.
Hi. I have a custom listview that consists of CheckedTextView
elements. I want to be able to check that at least one of the checkboxes is checked, and if not, keep the dialog on the screen. In order to implement this, I loop over the list items and check all of them. However, I could not find any way to keep the dialog open while onClick on positive is set. How should I proceed? Is there a way to implement a check in the onClick listener, and close or keep the dialog open according to the check result?
Thanks.
Hello, i love your work.
Everything is working very well, thank you so much. I want to change some colors but i cannot figure it out how to apply my own custom style from style.xml.
Please explain me when you have free time.
Thank you.
2.1
Hi is there any option to set the layout direction to RTL?
If not, can please add this option?
Thank you
My app (https://play.google.com/store/apps/details?id=vladyslavpohrebniakov.justtictactoe) uses this library. Can it be included here https://github.com/javiersantos/MaterialStyledDialogs#apps-already-using-this-library
I really like your lib and appreciate your efforts you put doing such a great work. If you mind, you could put our app into your showcase ๐
You can find our app on Google Play here
This issue is purely cosmetic
I would expect the dialog to animate smoothly from off screen
The dialog appears instantaneously with the header image showing, then the rest of the dialog is animated into view.
I just upgraded from Material Styled Dialog v1 to v1.5.5. Unfortunately, the latest version does not format descriptions correctly.
This is how the dialogue appears with v1:
The dialogue appears wrong in v1.5.5:
Am I missing a setting? Please help, thank you!
EDIT: I looked into this a bit further and the bug appears between v1.4 and v1.4.1
Seems that changing from a linear layout to a relative layout messed with the bottom margins/padding.
Hi,
The color of the description is also white and it isn't readable in my case. If you need any help let me know ;)
java.lang.RuntimeException: Binary XML file line #8: You must supply a layout_height attribute. at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:492) at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5755) at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5890) at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1815) at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1727) at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:58) at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog.initStyle(MaterialStyledDialog.java:324) at com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog.build(MaterialStyledDialog.java:268) at com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog.show(MaterialStyledDialog.java:307) at com.sjoprz.activity.Main$2.run(Main.java:197) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4947) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at dalvik.system.NativeStart.main(Native Method)
How can I get the value of an editText when I'm using a custom view?
This is my function code:
function askLogin(View view) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.login, null);
EditText school = (EditText) customView.findViewById(R.id.editTextSchool);
new MaterialStyledDialog(this)
.setDescription("Vul hier uw school en koppelcode in.")
.setCustomView(customView)
.setIcon(R.drawable.z)
.show();
}
This is the function I am calling when I click on the login button:
function logMeIn(View view) {
EditText school = (EditText) findViewById(R.id.editTextSchool);
System.out.println(schoolf.getText());
}
And this is my login.xml
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/editTextSchool" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="School" /> <EditText android:id="@+id/editTextKoppelcode" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Koppelcode" android:layout_below="@+id/editTextSchool" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </RelativeLayout> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" android:id="@+id/button20" android:layout_gravity="center_horizontal" android:onClick="aapje2" android:layout_centerHorizontal="true" />
What am I doing wrong?
The library works fine until i changed 1.3 to 1.4 in below line in gradle:
compile 'com.github.javiersantos:MaterialStyledDialogs:1.4'
error failed to resolve ..... is what i get. But when i change back to 1.3, it works fine.
jitpack.io has already been added to maven. Please help asap
As of now, if I want to have a header with a title (HEADER_WITH_TITLE
), as well as a headerDrawable
, the dialog builder adds a gray overlay of a color filter over that drawable:
if (this.style == Style.HEADER_WITH_TITLE) {
dialogHeader.setColorFilter(Color.rgb(123, 123, 123), Mode.MULTIPLY);
}
I have a background drawable that is already dark enough for text to be visible over it, and as such, would not need this filter to be added. It makes my header appear much darker than it should. Can we add a method to turn off this header filter?
Hi,
I tried to provide smaller description but it still is long for a smartphone and make the appearance of the dialog bad. The best solution is providing scrollable TextView
.
Is there a possibility of Adding a method to use custom typeface on all the text in the Dialog?
Somethin like .setTypeface?
it will be great if included ๐
I am new here and I want to ask is that a way to setSingleChoiceItems or setMultiChoiceItems to this dialog?
Because I cannot find it in any methods.
how can i add list of items
like string list
thanks
The buttons are aligned to the left side, I want them to be aligned to the right side and change the text size. How should I do that?
Hello .
I was wondering if there is any way to Add on Dismiss Listener ?
The About dialog gets dismissed on screen rotation. Is there a way to keep it after orientation change? See this StackOverflow question
Hi
After add to gradle this code, get error :
compile 'com.github.javiersantos:MaterialStyledDialogs:2.1'
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo
1: Enable / disable buttons
2: avoid Dialog from closing on click
How can I change or set my custom animation for the open/close animation of the dialog.
When I use that .setHeaderColor(R.color.primary_dark) to customize the color ever appera the same color )(like a grey) In the example og Google play the green example has the same problem
I use NExus 5 with Android 6
Hello @javiersantos, i need to know how to change button color.
I tried to add in styles.xml a style with parent MaterialStyledDialogs_Description in which i add an item called colorAccent but without result.
Could you help me? Thanks! ;)
How can I reuse the dialog's in a separate class?
With my attempt, I get a NullPointerException
:
Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference." at
FailDialogs.java:24
I just started diving back into Android/Java after a 5yr layoff so your help will be greatly appreciaded.
public class FailDialogs {
static Context context;
public static void invalidPasswordEmail() {
new MaterialStyledDialog.Builder(context) // <- This would be line 24
.setHeaderDrawable(R.drawable.shot_down)
.withDialogAnimation(true)
.setTitle(context.getString(R.string.dialog_warning))
.setDescription(context.getString(R.string.login_description_failed))
.setPositiveText(context.getString(R.string.login_positive_text_failed))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
/**
* Send the user to the Signup Activity If they
* realize they had not signed up yet or needs to
* create a new account via the action button.
*/
context.startActivity(new Intent(context, RegisterActivity.class));
}
})
.setNegativeText(R.string.login_negative_text_failed)
.show();
}
}
I'm accessing it with checkIfEmailVerified();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.