2011-03-13 124 views
11

我已经有了一个ProgressDialog,我已将其定位到屏幕的底部,以便不重叠徽标。我想要做的是为ProgressDialog创建一个自定义样式,用于删除背景和边框。我在这里没有任何运气。透明,无边界ProgressDialog

有没有人有关于如何应用这种风格的线索?

回答

9

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

This answer给出了详细的代码示例。

+0

似乎没有工作,如果我只是一个开箱即用的ProgressDialog,它只是忽略样式。我会尝试扩展自己的自定义对话框,看看会不会。 – madzilla 2011-03-13 23:12:11

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

+0

这可能会帮助你! – 2014-09-28 09:13:01

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> 

然后,把这段代码在你的活动或片段:

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