【发布时间】:2016-01-27 17:22:11
【问题描述】:
我在Fragment 中使用了一个简单的进度对话框生成器方法:
public void showProgressDialog(int messageId){
String message = getString(messageId);
mProgressDialog = ProgressDialog.show(this.getActivity(), "", message, true);
}
我应该怎么做才能在进度条周围设置默认填充?
编辑:添加主题.xml 文件
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">@android:color/white</item>
<item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item>
<!-- Material Theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/status_bar_color</item>
<item name="colorAccent">@color/accent_color</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">@android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawerArrowColor</item>
</style>
</resources>
此类在 API 级别 26 中已弃用。ProgressDialog 是一种模式 对话框,它会阻止用户与应用程序交互。反而 使用此类,您应该使用进度指示器,例如 ProgressBar,可以嵌入到应用程序的 UI 中。或者, 您可以使用通知来通知用户任务的进度。更多详情Link
【问题讨论】:
-
我猜是因为你没有传递
title值。为什么不给它一个合适的标题。或尝试传递" "而不是"" -
用title也试过了,没成功...
-
你在
android M上运行这个吗?你试过其他版本吗? -
不在android M上,但我使用
com.android.support:design:22.2.0和@style/Theme.AppCompat.Light.NoActionBar作为我的应用程序父主题,也许是主题? -
尝试使用这种风格
"@android:style/Theme.Dialog"