【问题标题】:How Make ProgressDialog Centered and no Background?如何让 ProgressDialog 居中且无背景?
【发布时间】:2013-06-17 08:38:23
【问题描述】:

我能够显示对话框,但无法使其居中且没有白色背景。如何以编程方式使 ProgressDialog 居中且无背景。谢谢^^

我的想法来自: ProgressDialog spinning circle ,但是我不能使用这个xml。

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:visibility="gone"
            android:indeterminateDrawable="@drawable/progress" >
        </ProgressBar>  

+++++++++++ 这是在 onPreExecute() 里面:

                pDialog = new ProgressDialog(Main_Activity.this);
                pDialog.setMessage("Loading products. Please wait...");
                pDialog.setIndeterminate(false);
                pDialog.setCancelable(false);
                pDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress));
                pDialog.show();

progress.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >

    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:thicknessRatio="8"
        android:useLevel="false" >
        <size
            android:height="48dip"
            android:width="48dip" />

        <gradient
            android:centerColor="#00FFFF"
            android:centerY="0.50"
            android:endColor="#0000FF"
            android:startColor="#0000A0"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate>

【问题讨论】:

    标签: java android xml android-layout


    【解决方案1】:

    您确定需要对话框吗?当然可以,但可能只是在布局上添加进度条并显示/隐藏它?

    【讨论】:

      猜你喜欢
      • 2023-01-27
      • 1970-01-01
      • 2023-03-29
      • 2012-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多