2017-04-04 10 views
1

私はスピナーで作業しており、ウィンドウの背景色を黒から白に変更したいと考えています。ここ は、プログレスダイアログのコードです:進行状況ダイアログの背景色を変更するにはどうすればいいですか?

 if (countProgress > 0) { 
     countProgress += 1; 
     return; 
    } 
    final ProgressDialog progressDialog = new ProgressDialog(activity, DialogFragment.STYLE_NO_TITLE); 
    progressDialog.setIndeterminateDrawable(activity.getResources().getDrawable(R.drawable.progress)); 
    progressDialog.setMessage(msg); 
    progressDialog.setCancelable(false); 
    progressDialog.setCanceledOnTouchOutside(false); 
    stackProgressDialog.push(progressDialog); 
    countProgress = 1; 
    activity.runOnUiThread(new Runnable() { 
     @Override 
     public void run() { 
      progressDialog.show(); 

     } 
    }); 

、ここでは描画可能xmlです:

<?xml version="1.0" encoding="utf-8"?> 
rotate xmlns:android="http://schemas.android.com/apk/res/android" 
android:drawable="@drawable/logo_only_64dp" 
android:pivotX="50%" 
android:pivotY="50%" 
android:fromDegrees="0" 
android:toDegrees="360" 
android:repeatCount="infinite"/> 

答えて

1

ステップ1:Theme.Dialogから継承テーマを定義します。

<style name="MyTheme" parent="@android:style/Theme.Dialog"> 
    <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item> 
    <item name="android:textColorPrimary">#000000</item> 
</style> 

ここで、ウィンドウ全体の背景色(質問の黄色)、フォントの色などを定義できます。本当に重要なのは、android:alertDialogStyleの定義です。このスタイルは、質問内の黒い領域の外観を制御します。

ステップ2:CustomAlertDialogStyleを定義します。

<style name="CustomAlertDialogStyle"> 
    <item name="android:bottomBright">@color/yellow</item> 
    <item name="android:bottomDark">@color/yellow</item> 
    <item name="android:bottomMedium">@color/yellow</item> 
    <item name="android:centerBright">@color/yellow</item> 
    <item name="android:centerDark">@color/yellow</item> 
    <item name="android:centerMedium">@color/yellow</item> 
    <item name="android:fullBright">@color/yellow</item> 
    <item name="android:fullDark">@color/yellow</item> 
    <item name="android:topBright">@color/yellow</item> 
    <item name="android:topDark">@color/yellow</item> 
</style> 

これは黄色への質問で黒の領域を設定します。

ステップ3:ProgressDialogにMyThemeを適用し、ないCustomAlertDialogStyle:

ProgressDialogダイアログ=新ProgressDialog(これ、R.style.MyTheme)。

+0

ありがとう、それは私の問題を解決するために私を助けた! – GAD

+0

あなたは歓迎です、あなたは答えを受け入れることができますか? –

関連する問題