Ich habe eine Aktivität in meinem Manifest, die ich früher mit einem Dialogthema gestylt habe. Ich kann nicht finden, wie man dieses in der AppCompat
Bibliothek ersetzt.
<activity
Android:name=".LoginActivity"
Android:theme="@Android:styles/Theme.Holo.Dialog"
Android:configChanges="orientation|screenSize|keyboardHidden"
Android:label="Login" >
Gibt es ein materialbasiertes Äquivalent?
Es gibt noch kein materialbasiertes Thema für einen Dialog in AppCompat, siehe hier
Will appcompat automatically theme dialogs to look like the Lollipop version?
Antwort
Not yet, but it's on the todo list.
Update:
In Version 22.1
des Support Library
Sie können jetzt den Materialdialogstil mit AppCompatDialog abrufen
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();
Verwenden Sie dieses Thema
<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>
Warndialog für Importsupport v7
import Android.support.v7.app.AlertDialog;
Ausgabe wie folgt
Verwenden Sie die neueste Appcompat-Bibliothek
compile 'com.Android.support:appcompat-v7:23.2.1'// or any version greater than 22.1
verwenden Sie im Manifest das folgende Thema
Android:theme="@style/Theme.AppCompat.Light.Dialog"
Dies sollte für Sie funktionieren: https://github.com/afollestad/material-dialogs
Ich habe es verwendet, um den Dialog in einem DialogFragment
mit benutzerdefinierten Stilen zu erstellen. Funktioniert super.