24

ダイアログテーマでスタイルを設定していたマニフェストにアクティビティがあります。AppCompatライブラリでこれを置き換える方法が見つかりません。

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

マテリアルベースの同等品はありますか?

4

4 に答える 4

59

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;

このような出力、

ここに画像の説明を入力

于 2015-06-22T08:20:14.427 に答える
26

AppCompat にはダイアログ用のマテリアル ベースのテーマはまだありません。こちらを参照してください。

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

応答

Not yet, but it's on the todo list.

アップデート:

のバージョン22.1では、AppCompatDialogSupport Libraryを使用してマテリアル ダイアログ スタイルを取得できるようになりました

于 2014-10-24T19:15:35.367 に答える
9

最新の Appcompat ライブラリを使用する

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

マニフェストでは、次のテーマを使用します

android:theme="@style/Theme.AppCompat.Light.Dialog"
于 2016-04-02T15:13:55.780 に答える
0

これはうまくいくはずです:https://github.com/afollestad/material-dialogs

DialogFragmentこれを使用して、カスタム スタイルを適用した でダイアログを作成しました。よく働く。

于 2015-02-08T22:25:27.630 に答える