我的ProgressDialog中的进度条大小有问题。如何在ProgressDialog中更改我的进度条的形状大小?它应该是细线(1dip),但它大于1dip。
pd = new ProgressDialog(context, R.style.testing);
pd.setMessage(context.getString(R.string.sr_progress_bar_message));
pd.setCancelable(false);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setProgress(0);
pd.show();
风格:
<style name="testing" parent="Theme.AppCompat.Dialog">
<item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
<item name="android:background">@color/color_primary</item>
</style>
<style name="CustomAlertDialogStyle1">
<item name="android:bottomBright">@android:color/transparent</item>
<item name="android:bottomDark">@android:color/transparent</item>
<item name="android:bottomMedium">@android:color/transparent</item>
<item name="android:centerBright">@android:color/transparent</item>
<item name="android:centerDark">@android:color/transparent</item>
<item name="android:centerMedium">@android:color/transparent</item>
<item name="android:fullBright">@android:color/transparent</item>
<item name="android:fullDark">@android:color/transparent</item>
<item name="android:topBright">@android:color/transparent</item>
<item name="android:topDark">@android:color/transparent</item>
</style>
Definiton:
pd.setProgressDrawable(context.getResources()getDrawable(R.drawable.progress_dialog));
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<size android:maxHeight="1dip" />
<size android:minHeight="1dip" />
<solid android:color="#808080"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<size android:maxHeight="1dip" />
<size android:minHeight="1dip" />
<solid android:color="#80ff0000"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<size android:maxHeight="1dip" />
<size android:minHeight="1dip" />
<solid android:color="#ff0000"/>
</shape>
</clip>
</item>
</layer-list>