我正在使用以下代码来显示进度条
,以满足我的需求:
public class DelayedProgressDialog extends DialogFragment
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setCancelable(false);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setTitle(null);
dialog.setContentView(R.layout._task);
dialog.setIndeterminate(false);
return dialog;
}
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="@dimen/_100sdp"
android:layout_height="@dimen/_100sdp"
android:id="@+id/progressBar"
android:layout_centerInParent="true"
android:indeterminateTint="@android:color/white"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
现在的问题是,当我调用以下内容时,我的自定义进度条未显示在此片段中: 在左侧显示正常进度条而没有标题,我想要在中心显示。如果我删除setContentview,则不会有任何效果,这意味着我的自定义视图未在其中显示,我该如何将我的视图显示在其中。