Create a progressDialog only with the spinner (in the middle)

后端 未结 2 661
抹茶落季
抹茶落季 2020-12-04 22:12

I need to create a progressDialog only with the spinner and without the box (or at least with a smaller box and the image in the middle).

I don\'t want to add a spin

相关标签:
2条回答
  • 2020-12-04 22:58

    Just single line code :

    pd.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    
    0 讨论(0)
  • 2020-12-04 23:04

    try this way:

    pd = new ProgressDialog(Login.this,R.style.MyTheme);
    pd.setCancelable(false);
    pd.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
    pd.show();
    

    And create Theme in values\styles.xml

     <style name="MyTheme" parent="android:Theme.Holo.Dialog">
        <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
        <item name="android:windowBackground">@color/transparent</item>
        <item name="android:textColorPrimary">#FFFFFF</item>
         <item name="android:backgroundDimEnabled">false</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textSize">12sp</item>
    </style>
    

    And also add this Theme in values\styles.xml

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

    And add values\colors.xml

    <color name="transparent">#00000000</color>
    
    0 讨论(0)
提交回复
热议问题