我想显示在我的视图一个模态的进展“车轮”重叠。

在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代码)。

有帮助吗?

解决方案

你检查出这个教程?在页面的到底是谈如何创建一个自定义对话框,并可以帮助你把微调进度对话框与自己的背景。

其他提示

不知道是否有更好的办法,但你可以通过使用的进度并设定它是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>

为了创建在黑暗背景我使用的FrameLayout和所需或GONE时当长操作完成设置的RelativeLayout到VISIBLE的可视性全屏进展:

<?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>

Klarth的解决方案为我,谢谢!

在我的情况下我用layout_gravity为progress_indicator的中心放置,而不是使用显式的坐标。

    <ProgressBar android:id="@+id/pb"
        android:layout_width="40dp" 
        android:layout_height="40dp"
        android:indeterminate="true" 
        android:indeterminateOnly="true"
        android:isScrollContainer="true" 
        android:layout_gravity="center_vertical|center_horizontal"
        android:soundEffectsEnabled="false"
        />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top