【问题标题】:Create a progressDialog only with the spinner (in the middle)仅使用微调器(在中间)创建progressDialog
【发布时间】:2014-02-13 10:34:50
【问题描述】:

我只需要使用微调器和不带框(或至少使用较小的框和中间的图像)创建一个progressDialog。

我不想在我的 .xml(布局文件)中添加微调器来加载微调器。

有没有办法做到这一点?谢谢!

【问题讨论】:

标签: android android-spinner android-progressbar


【解决方案1】:

试试这个方法:

pd = new ProgressDialog(Login.this,R.style.MyTheme);
pd.setCancelable(false);
pd.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
pd.show();

并在values\styles.xml

中创建主题
 <style name="MyTheme" parent="android:Theme.Holo.Dialog">
    <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:textColorPrimary">#FFFFFF</item>
     <item name="android:backgroundDimEnabled">false</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textStyle">normal</item>
    <item name="android:textSize">12sp</item>
</style>

并且在values\styles.xml中添加这个主题

 <style name="CustomAlertDialogStyle">
    <item name="android:bottomBright">@color/transparent</item>
    <item name="android:bottomDark">@color/transparent</item>
    <item name="android:bottomMedium">@color/transparent</item>
    <item name="android:centerBright">@color/transparent</item>
    <item name="android:centerDark">@color/transparent</item>
    <item name="android:centerMedium">@color/transparent</item>
    <item name="android:fullBright">@color/transparent</item>
    <item name="android:fullDark">@color/transparent</item>
    <item name="android:topBright">@color/transparent</item>
    <item name="android:topDark">@color/transparent</item>
</style>

并添加values\colors.xml

<color name="transparent">#00000000</color>

【讨论】:

  • 如何更改进度圈颜色
  • 要改变进度对话框的颜色,你可以使用: ProgressDialog dialog = ProgressDialog.show(MainActivity.this, null,null); ProgressBar spinner = new android.widget.ProgressBar(MainActivity.this, null,android.R.attr.progressBarStyle); spinner.getIndeterminateDrawable().setColorFilter(Color.parseColor("#53CBF1"), android.graphics.PorterDuff.Mode.SRC_IN); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(微调器); dialog.setCancelable(false);对话框.show();
【解决方案2】:

单行代码:

pd.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

【讨论】:

  • 如何获取窗口中间的圆圈?
  • @hetsgandhi 如果您想自定义整个进度对话框,那么只需扩展 Dialog 并创建您自己的视图。顺便说一句,进度对话框现在已被弃用。
  • 那么除了任何库还应该使用什么?
  • @hetsgandhi 使用进度条。如果要禁用触摸,则可以将标志设置为窗口: window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) 并使用以下方法启用触摸: window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-09
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
相关资源
最近更新 更多