Подтвердить что ты не робот

Использование темы диалога на основе материалов с помощью AppCompat

У меня есть активность в моем манифесте, который я использовал для стиля с помощью темы "Диалог". Я не могу найти, как заменить это в библиотеке AppCompat.

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

Существует ли эквивалент на основе материала?

4b9b3361

Ответ 1

В AppCompat еще нет темы, основанной на материалах, см. здесь

Will appcompat automatically theme dialogs to look like the Lollipop version?

Ответ

Not yet, but it on the todo list.

Update:

В версии 22.1 Support Library теперь вы можете получить стиль диалогового окна материала, используя AppCompatDialog

Ответ 2

Java-код

    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();

Используйте эту тему

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

Поддержка импорта v7 предупреждение

import android.support.v7.app.AlertDialog;

Результат, подобный этому,

enter image description here

Ответ 3

Использовать последнюю библиотеку Appompat

compile 'com.android.support:appcompat-v7:23.2.1'// or any version greater than 22.1

а в манифесте используйте следующую тему

android:theme="@style/Theme.AppCompat.Light.Dialog"

Ответ 4

Это должно сработать для вас: https://github.com/afollestad/material-dialogs

Я использовал его для создания диалога в DialogFragment, с использованием пользовательских стилей. Отлично работает.