レイアウトでrecyclerviewの代わりにカスタムの空のビューを追加することにはほとんど問題がありません。私のカスタム空のビューは "center_vertical"として重力を持っています。このように追加すると、カスタムの空のビューに追加された画像とテキストが、リストビューが表示されている領域の下に隠れてしまいます。画面から外れています。 SwipeRefreshLayoutの "appbar_scrolling_view_behavior"のために起こっていると思います。しかし、リストをスクロールするときに、Appbarがスクロールするようにする必要があります。しかし、データが表示されない場合は、カスタム空のビューのイメージを画面中央のappbarlayoutの下に表示します。現在、画面の下にプッシュされています。以下のRecyclerViewの代わりに空のビューを追加するAppBarLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/headRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
app:layout_scrollFlags="scroll|enterAlways">
<include
android:id="@+id/topLayout"
layout="@layout/top_sch_listview" />
<include
android:id="@+id/msgLayout"
layout="@layout/view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/topLayout" />
<include
android:id="@+id/subHeaderLayout"
layout="@layout/view_sub_header"
android:layout_width="match_parent"
android:layout_height="@dimen/sub_header_height"
android:layout_below="@+id/msgLayout" />
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
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/recyclerListView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.my.views.CustomEmptyView
android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<View
android:id="@+id/blankView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
</android.support.design.widget.CoordinatorLayout>
私が間違っていることはわかりません。助けてもらえますか?
ありがとうございました。
をnotifyDataSetChanged。同じように動作します。 – Neha
私はまだそれを試みました。しかし、動作しませんでした。 – Neha