【问题标题】:Transparent, borderless ProgressDialog透明无边框 ProgressDialog
【发布时间】:2011-03-13 20:01:21
【问题描述】:

我有一个ProgressDialog,我已将其放置在屏幕底部,以免与徽标重叠。我想做的是为ProgressDialog 创建一个自定义样式,删除背景和边框。我在这里运气不好。

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

【问题讨论】:

    标签: android


    【解决方案1】:

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

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

    【讨论】:

    • 如果我只是为开箱即用的 ProgressDialog 设置样式似乎不起作用,它只是忽略了样式。我会尝试扩展我自己的自定义对话框,看看是否可行。
    【解决方案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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 2011-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        • 2013-01-24
        • 1970-01-01
        相关资源
        最近更新 更多