部分屏幕上的进度对话框

时间:2017-07-04 06:20:55

标签: android android-fragments progressdialog

我有一个包含三个标签的片段。在其中一个选项卡上,我有一个对话框,当后台同步进行时会旋转。但是,当后台同步进行时,我需要能够继续处理其他部分。

我目前正在使用dialog.setCancelable(false)退出对话框,以便我可以使用该应用的其余部分。但是这给了我一个关于同步进行的片段的情感屏幕。

有没有办法让对话框只覆盖屏幕的一部分(只有同步进行的片段)?换句话说,一个不占用整个屏幕的对话框,以便我可以移动到其他选项卡而不取消对话框?

在java代码中实现对话框:

    dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_PROGRESS);
    dialog.setCancelable(true);
    dialog.setContentView(R.layout.dialog_progress_bar);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

dialog.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ProgressBar
        android:id="@+id/dialogProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>

</LinearLayout>

1 个答案:

答案 0 :(得分:1)

不,您无法使用Dialog实现此行为。

#。当您使用Fragment并希望显示同步的progress时,我认为您可以在片段ProgressBar中添加layout Dialog 1}} XML而不是使用ProgressBar并按sync状态显示/隐藏going on

状态:

  1. 当同步为ProgressBar时,仅显示Views并隐藏其他completed
  2. 同步ProgressBar时,隐藏Views并根据您的需要向其他人显示layout
  3. #。您还可以在片段show XML中使用SwipeRefreshLayout来表明进度正在进行中。 ProgressBar进行sync hide sync {{1}}自{{1}}完成{/ 1}}。

    这是一个很好的教程:Android Swipe Down to Refresh ListView Tutorial

    希望这会有所帮助〜

相关问题