2

AndroidでProgressDialogスタイルを変更するには? 背景色とテキストの色を変更する必要があります。

アプリに 1 つのスタイルしかありません。進行状況ダイアログのスタイルを変更するには、どの項目をオーバーライドする必要がありますか?

コーディングせずにxmlだけでスタイルを変えたいです。可能ですか?

PS:

プログレスバーがありません!進行状況ダイアログがあります。そして、リストビュー、ウィンドウの背景などのスタイルを変更するように、スタイルとテーマを使用してスタイルを変更したいと思います.

4

2 に答える 2

9

ProgressDialog のテーマは次のように変更できます。

ProgressDialog dialog = new ProgressDialog(this, AlertDialog.THEME_HOLO_DARK);
dialog.setTitle("Title");
dialog.setMessage("Message");
dialog.show();
于 2013-04-16T15:39:39.687 に答える
3

カスタム ダイアログバーのコード: drawable の下のファイルは、さまざまな状態の色を宣言します。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/background">
        <shape>
            <gradient
                    android:startColor="#000001"
                    android:centerColor="#0b131e"
                    android:centerY="0.75"
                    android:endColor="#0d1522"
                    android:angle="270"
            />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <gradient
                        android:startColor="#234"
                        android:centerColor="#234"
                        android:centerY="0.75"
                        android:endColor="#a24"
                        android:angle="270"
                />
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <gradient
                    android:startColor="#144281"
                    android:centerColor="#0b1f3c"
                    android:centerY="0.75"
                    android:endColor="#06101d"
                    android:angle="270"
                />
            </shape>
        </clip>
    </item>

</layer-list>

レイアウト xml 内のコード:

<ProgressBar android:id="@+id/progressBar"
    android:progressDrawable="@drawable/progress_bar_states"
    android:layout_width="fill_parent" android:layout_height="8dip" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:indeterminateOnly="false" 
    android:max="100">
</ProgressBar>
于 2012-04-20T07:42:28.260 に答える