2011-03-13 61 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會在沒有背景和邊框顯示。