【问题标题】:Change style of ProgressDialog更改 ProgressDialog 的样式
【发布时间】:2012-02-23 00:34:46
【问题描述】:

是否可以更改进度对话框的 ProgressBar 样式。如果是,那我该怎么做?

【问题讨论】:

标签: android coding-style progress-bar progressdialog


【解决方案1】:

您可以通过以下方式设置进度对话框的样式: 用你的环形创建一个可绘制的文件 (circular_progress_dialog.xml)

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
    android:innerRadiusRatio="2.5"
    android:shape="ring"
    android:thickness="2dp"
    android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

    <gradient
        android:angle="0"
        android:endColor="@color/main_background"
        android:startColor="@color/main_orange"
        android:type="sweep"
        android:useLevel="false" />
</shape>
</rotate>

一个样式你的进度条

 <style name="ProgressBar" parent="@android:style/Widget.ProgressBar">
    <item name="android:layout_centerHorizontal">true</item>
    <item name="android:layout_centerVertical">true</item>
    <item name="android:visibility">gone</item>
    <item name="android:background">@color/transparency_pleca</item>
    <item name="android:indeterminateDrawable">@drawable/circular_progress_dialog</item>
</style>

注意你的“android:indeterminateDrawable”属性

您可以创建ProgressDialog 的实例并添加您的样式

// create progressDialog
final ProgressDialog myProgressDialog = new  ProgressDialog(MyActivity.this);
myProgressDialog.setProgressStyle(R.style.ProgressBar)
myProgressDialog.show();

【讨论】:

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