A Material styled AlertDialog

Are you looking for a Material styled AlertDialog?

Here a short gist to migrate the "old" AlertDialog
 AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Dialog");
        builder.setMessage("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo,");
        builder.setPositiveButton("OK", null);
        builder.setNegativeButton("Cancel", null);
        builder.show();

Now you can use the new android.support.v7.app.AlertDialog and the the code becomes:

import android.support.v7.app.AlertDialog;

  AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
        builder.setTitle("Dialog");
        builder.setMessage("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo,");
        builder.setPositiveButton("OK", null);
        builder.setNegativeButton("Cancel", null);
        builder.show();
using this style:

   <style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">#FFCC00</item>
        <item name="android:textColorPrimary">#FFFFFF</item>
        <item name="android:background">#5fa3d0</item>
    </style>
and you can enjoy your material styled Dialog on Kitkat:


or on Lollipop:

If you would like tu use a custom style for the title (for example) you can use a style like this:

    <style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">#FFCC00</item>
        <item name="android:textColorPrimary">#FFFFFF</item>
        <item name="android:background">#5fa3d0</item>

        <item name="android:windowTitleStyle">@style/TitleDialogTextStyle</item>
    </style>

    <style name="TitleDialogTextStyle" parent="Base.DialogWindowTitle.AppCompat">
        <item name="android:textColor">#d71616</item>
    </style>

Comments

  1. Do you understand there is a 12 word sentence you can say to your crush... that will induce intense feelings of love and impulsive appeal for you buried within his heart?

    That's because hidden in these 12 words is a "secret signal" that fuels a man's impulse to love, idolize and care for you with his entire heart...

    ====> 12 Words Who Trigger A Man's Desire Response

    This impulse is so built-in to a man's brain that it will make him try better than before to take care of you.

    Matter-of-fact, triggering this mighty impulse is absolutely binding to having the best possible relationship with your man that the second you send your man a "Secret Signal"...

    ...You'll soon find him open his mind and soul to you in such a way he never expressed before and he'll perceive you as the one and only woman in the universe who has ever truly interested him.

    ReplyDelete
  2. There are many blogs and articles I have read, but yours have been very helpful. Thank you. Thanks for sharing this information. Additionally, I have a dedicated profile Right Click CPS Test with more information. Please let me know what you think by clicking here Right Click Speed Test.

    ReplyDelete
  3. Hi, just wanted to say, I loved this post. It was practical. Keep on posting! It's awesome designed for me to have a web site, which is helpful designed for my knowledge.
    섯다

    ReplyDelete
  4. What’s up, yes this paragraph is really good and I have learned lot of things from it concerning blogging.
    한국야동

    ReplyDelete
  5. This is an incredible post I seen on account of offer it. It is truly what I needed to see seek in future you will proceed after sharing such a magnificent post. 바카라사이트인포

    ReplyDelete
  6. Fantastic internet site! It appeals to my eyes since it is basic. I'm investigating how I may be notified whenever a new article is released. Changes that have occurred recently are expected. The most exciting piece on this subject that can be found is about getting the most up-to-date advice on the internet concerning british airways manage trip . Have a fantastic day!

    ReplyDelete
  7. Hello very nice article!! Excellent & Wonderful. I’ll bookmark this website.

    ReplyDelete
  8. Pay a quick visit this website, it includes valuable Information here. Goodluck!

    ReplyDelete
  9. After reading this article I was amazed. You explain it well. Keep on blogging, thanks!

    ReplyDelete
  10. Its awesome, I admire this blog here. Awesome article, keep doing it! thanks!

    ReplyDelete
  11. Very nice article and straight to the point. Keep it up, Thank you, so awesome!

    ReplyDelete
  12. This is a great blog post, thanks for sharing. Really excited to read more desire more!

    ReplyDelete
  13. I really enjoyed your blog post. Really excited to read more. Amazingly cool!

    ReplyDelete

Post a Comment

Popular posts from this blog

AntiPattern: freezing a UI with Broadcast Receiver

NotificationListenerService and kitkat

How to centralize the support libraries dependencies in gradle