Android的进度条显示不出来

问题描述 投票:0回答:1

这是我的布局XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/fragment_body"
android:fitsSystemWindows="true">

<include
    android:id="@+id/contextToolBar"
    layout="@layout/context_toolbar_layout" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/list1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/contextToolBar"
    android:scrollbarSize="5dp"
    android:scrollbarThumbVertical="@color/scrollbarColor"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<ProgressBar
    android:id="@+id/delete_progress"
    style="@style/Widget.AppCompat.ProgressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:visibility="gone" />

它显示在recyclerview图像的网格。我可以选择一些图片,和有一个选项,将其删除。以下是删除逻辑:

public void deleteSelectedFiles(final Context context, final List<MediaModel> selectionList) {

    String confirmationMessage = getString(R.string.delete_confirm_message);

    new AlertDialog.Builder(context)
            .setTitle(getString(R.string.action_delete))
            .setMessage(confirmationMessage)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
                View progressBar = getActivity().findViewById(R.id.delete_progress);
                dialog.cancel();
                progressBar.setVisibility(View.VISIBLE);

                deleteFileList(selectionList, this.getActivity());

                progressBar.setVisibility(View.GONE);
            })
            .setNegativeButton(android.R.string.no, null).show();
}

我期待进度条,而删除操作将会在前台显示。但它只是不露面。任何帮助将高度赞赏。

android android-layout android-recyclerview progress-bar android-progressbar
1个回答
4
投票

所以我以前出现过此问题。在我的情况,那是因为我是用整个应用物料设计主题,所以我不得不使用一个特定的方向,它解决了我的问题。你可以试试

<ProgressBar
                android:id="@+id/progressBarReady"
                style="@android:style/Widget.ProgressBar.Horizontal"
                android:layout_width="match_parent"
                android:layout_height="3dp"
                android:indeterminate="true"
                android:visibility="visible"/>
© www.soinside.com 2019 - 2024. All rights reserved.