Edw*_*Lee 7 android progressdialog
我想在我的视图中显示模态进度"轮"叠加.
ProgressDialog接近,但我不想要对话框背景或边框.
我尝试设置对话框窗口的背景drawable:
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();
Run Code Online (Sandbox Code Playgroud)
但无济于事(即看起来仍然没有... setBackgroundDrawable代码).
Kla*_*rth 12
不确定是否有更好的方法,但你可以通过使用ProgressBar并将其设置为interdeterminate来自己获得微调轮.如果您使用的是AbsoluteLayout,则可以将其放在其他视图上.此布局应使用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>
Run Code Online (Sandbox Code Playgroud)
EZD*_*sIt 10
为了在黑暗的背景上创建全屏幕进度,我使用FrameLayout并在需要时将RelativeLayout的可见性设置为VISIBLE,或者在完成长操作时将GONE设置为GONE:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:padding="3dip" >
<!-- Your regular UI here -->
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativelayout_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="#aa000022" >
<ProgressBar
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateOnly="true" />
</RelativeLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)