Подтвердить что ты не робот

Создайте progressDialog только со счетчиком (посередине)

Мне нужно создать progressDialog только со счетчиком и без коробки (или, по крайней мере, с меньшим ящиком и изображением в середине).

Я не хочу добавлять spinner в свой .xml(файл макета), чтобы загрузить spinner.

Есть ли способ сделать это? Спасибо!

enter image description here

4b9b3361

Ответ 1

попробуйте следующим образом:

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

И создайте Тема в 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>

А также добавьте эту тему в 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>

И добавьте values\colors.xml

<color name="transparent">#00000000</color>

Ответ 2

Только однострочный код:

pd.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));