问题 透明,无边界的ProgressDialog


我有一个 ProgressDialog 我已经定位到我的屏幕底部,因为没有重叠徽标。我想要做的是创建一个自定义样式 ProgressDialog 删除背景和边框。我在这里没有运气。

有没有人知道如何应用这种风格?


11839
2018-03-13 20:01


起源



答案:


您是否尝试将背景设置为透明色?

这个答案 给出了详细的代码示例。


9
2018-03-13 20:30



如果我只是开箱即用的ProgressDialog样式似乎没有用,它只是忽略了样式。我将尝试扩展自己的自定义对话框,看看是否会这样做。 - madzilla


答案:


您是否尝试将背景设置为透明色?

这个答案 给出了详细的代码示例。


9
2018-03-13 20:30



如果我只是开箱即用的ProgressDialog样式似乎没有用,它只是忽略了样式。我将尝试扩展自己的自定义对话框,看看是否会这样做。 - madzilla


您可以将图像用于进度对话框并根据需要进行自定义 -

         // Custom position Of image Loader
          WindowManager.LayoutParams wmlp =
          pDialog.getWindow().getAttributes(); int height =
          getResources().getDisplayMetrics().heightPixels; wmlp.y =
          height/4; pDialog.getWindow().setAttributes(wmlp);

有关详细信息,请访问以下链接:

http://androiddubd.blogspot.com/2014/09/how-to-create-transparent-progress.html


2
2017-09-07 11:40



这可能对你有所帮助! - Md. Ilyas Hasan Mamun


这可以帮助你(为我工作):

在res / layout中创建一个布局,如下所示(例如,命名为progressbar.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" >

   <ProgressBar
      android:id="@+id/progressBar"
      style="?android:attr/progressBarStyleLarge"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true" />
</RelativeLayout>

然后,将此代码放入Activity或Fragment中:

private ProgressDialog progressDialog;

// the first parameter (this) is your activity
// ... but if you need to use this code in a Fragment, use getActivity() instead 
progressDialog = ProgressDialog.show(this,null,null);  
progressDialog.setContentView(R.layout.progressbar);

因此,ProgressDialog将显示没有背景和边框。


2
2018-04-13 01:57