透明,无边界的ProgressDialog

时间:2011-03-13 20:01:21

标签: android

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

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

3 个答案:

答案 0 :(得分:9)

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

This answer提供了详细的代码示例。

答案 1 :(得分:2)

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

         // 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 :(得分:2)

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

在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将显示没有背景和边框。

相关问题