Использование темы диалога на основе материалов с AppCompat
у меня есть действие в моем Манифесте, которое я использовал для стиля с диалоговой темой. Я не могу найти как заменить на AppCompat
библиотека.
<activity
android:name=".LoginActivity"
android:theme="@android:styles/Theme.Holo.Dialog"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="Login" >
есть ли материальный эквивалент?
4 ответов
в AppCompat еще нет темы на основе материалов для диалога, см. здесь
Will appcompat automatically theme dialogs to look like the Lollipop version?
ответ
Not yet, but it's on the todo list.
обновление:
в версии 22.1
на Support Library
Теперь вы можете получить стиль диалога материала с помощью AppCompatDialog
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 Alert dialog
import android.support.v7.app.AlertDialog;
выводим вот так,
используйте последнюю библиотеку Appcompat
compile 'com.android.support:appcompat-v7:23.2.1'// or any version greater than 22.1
и в Манифесте используйте следующую тему
android:theme="@style/Theme.AppCompat.Light.Dialog"
Это должно работать для вас: https://github.com/afollestad/material-dialogs
я использовал его для создания диалога в DialogFragment
, с пользовательских стилей, примененных. Отлично работает.