【发布时间】:2017-06-14 12:53:51
【问题描述】:
我在片段中有一个回收器视图,我想在填充数据之前显示进度条。 ProgressBar 显示在 actionBar 附近的 centerTop 上,而不是屏幕中间。下面是我的 recyclerview 和进度条的布局 xml。我希望进度条显示在屏幕中间。
recyclerview.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"/>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
android:orientation="vertical"
android:paddingTop="?attr/actionBarSize"
android:fitsSystemWindows="true"
tools:context="com.example.test.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/recyclerview" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
这就是我得到的
【问题讨论】:
-
尝试将
android:layout_height="match_parent"用于RecyclerView -
@A.A.它仍然无法正常工作
标签: android android-fragments android-recyclerview android-progressbar