Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a Material-based Dialog Theme with AppCompat

Tags:

I have an activity in my Manifest I used to style with a Dialog Theme. I can not find how to replace this in AppCompat library.

  <activity             android:name=".LoginActivity"             android:theme="@android:styles/Theme.Holo.Dialog"              android:configChanges="orientation|screenSize|keyboardHidden"             android:label="Login" > 

Is there a Material-based equivalent?

like image 951
TheLettuceMaster Avatar asked Oct 24 '14 19:10

TheLettuceMaster


1 Answers

Java code

    AlertDialog.Builder builder =                     new AlertDialog.Builder(SecondActivity.this, R.style.AppCompatAlertDialogStyle);             builder.setTitle("SCRUM");             builder.setMessage("In the SCRUM methodology a sprint is the basic unit of development. Each sprint is preceded by a planning meeting, where the tasks for the sprint are identified and an estimated commitment for the sprint goal is made, and followed by a review or retrospective meeting where the progress is reviewed and lessons for the next sprint are identified. During each sprint, the team creates finished portions of a product.....");             builder.setPositiveButton("OK", null);//second parameter used for onclicklistener             builder.setNegativeButton("Cancel", null);             builder.show(); 

Use this theme

  <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> 

Import support v7 alert dialog

import android.support.v7.app.AlertDialog; 

Output like this,

enter image description here

like image 104
Ranjithkumar Avatar answered Oct 21 '22 00:10

Ranjithkumar