我正在尝试使用自定义背景进行自定义进度对话框。我找到 this自定义进度对话框的示例,但我需要将其背景颜色从黑色更改为蓝色。 我试图改变这一行
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
在那个例子的 styles.xml 中,但这不是我需要的...
我做错了什么?
我试图以这种方式更改您的 xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3300CC"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#3300CC"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
但是底线没有填充颜色
现在有什么问题?
我需要这样的对话框
最佳答案
试试这个:
ProgressDialog mProgressDialog = ProgressDialog.show(MainActivity.this, "", "");
mProgressDialog.setContentView(R.layout.main);
mProgressDialog.show();
和 main.xml 类似:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="135dp"
android:layout_height="56dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="146dp"
android:background="#3300CC"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:indeterminateDrawable="@drawable/custom_progress"
android:max="10000"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/progressBar1"
android:text="Please wait..." />
</RelativeLayout>
</RelativeLayout>
请将 custom_progress.xml 添加到您的可绘制对象中:
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080">
<shape android:shape="ring"
android:innerRadiusRatio="5"
android:thicknessRatio="20"
android:useLevel="false">
<gradient
android:type="sweep"
android:useLevel="false"
android:startColor="#FFFFFF"
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#0D8FDB" />
</shape>
</rotate>
关于android进度对话框背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21499935/