Android:如何创建模态进度“轮”叠加层?

2024-05-15

我想在我的视图上显示模式进度“轮子”叠加层。

ProgressDialog 很接近,但我不想要对话框背景或边框。

我尝试设置对话框窗口的背景可绘制:

this.progressDialog = new ProgressDialog(Main.this);

this.progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
this.progressDialog.setCancelable(false);
this.progressDialog.setIndeterminate(true);

this.progressDialog.show();

但无济于事(即看起来仍然与没有 ...setBackgroundDrawable 代码相同)。


不确定是否有更好的方法,但您可以使用进度条 http://developer.android.com/reference/android/widget/ProgressBar.html并将其设置为不确定的。如果您正在使用绝对布局 http://developer.android.com/reference/android/widget/AbsoluteLayout.html您可以将其放在其他视图之上。此布局应使用 XML 演示此方法:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout android:id="@+id/AbsoluteLayout"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ProgressBar android:id="@+id/ProgressBar"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:indeterminate="true" android:indeterminateOnly="true"
        android:isScrollContainer="true" android:layout_x="100dip"
        android:layout_y="10dip" android:soundEffectsEnabled="true"></ProgressBar>
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="@string/hello"
        android:layout_gravity="center_horizontal" android:gravity="center_horizontal"
        android:layout_y="25dip" />
</AbsoluteLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android:如何创建模态进度“轮”叠加层? 的相关文章

随机推荐