【发布时间】:2016-05-03 07:49:06
【问题描述】:
我想在使用 RecyclerView 加载更多数据时在列表末尾显示一个进度条。只是为了测试,我将它设置为始终可见,但它根本不可见。我试图将它放在 LinearLayout 中,但这没有帮助。
这是我的片段:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/latestnews_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_latestnews"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:id="@+id/loadmore_progressBar"
android:layout_width="45dp"
android:layout_height="45dp"
android:indeterminate="true"
android:layout_gravity="center"
android:visibility="visible" />
</LinearLayout>
Fragment 在 viewpager 中加载:
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
【问题讨论】:
-
当然是不可见的,将
recyclerView设置为fill_parent时不允许它可见 -
@Pztar,我把recyclerview改成
wrap_content,还是看不到进度条。 -
你不能那样做。将您的
RefreshLayout设置为像300dp这样的设置高度,然后您会看到进度条 -
@Pztar 将其设置为硬编码数字是没有用的,也不是我想要的。有没有办法在recyclerview上显示进度条??
-
另外作为旁注
fill_parent已弃用,使用match_parent代替它做同样的事情,不要使用px值使用dp
标签: android android-fragments progress-bar