Good day, sirs!
I have an Activity with a TabLayout+ViewPager and 2 Fragments in it. In the first Fragment I have a RecyclerView with some items and the SearchView in the Toolbar. I want to show the placeholder when your search query makes RecyclerView disappear (I mean you found no results and RecyclerView.setVisibility(GONE)
). So there's my Fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pale_grey">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@android:color/darker_gray"
android:scrollbarSize="4dp"/>
<LinearLayout
android:id="@+id/ll_no_categories"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/toolbar"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="24dp"
android:visibility="visible"
app:srcCompat="@drawable/vector_search_big" />
<TextView
android:id="@+id/tv_no_categories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/activity_home_services_category_list_empty"
android:textColor="@color/black_40"
android:textSize="16sp"/>
</LinearLayout>
</RelativeLayout>
So when my ItemList.size = 0
I set RecyclerView to GONE
and LinearLayout
to VISIBLE
. The problem I got: adjustResize
in Manifest of my Activity doesn't work for Fragment in this Activity - placeholder still under the keyboard by half. I did the same thing in the Activity without Fragment and the only thing I did - set adjustResize
in Activity Manifest. How to deal with this problem with Fragment?
UPD: Well, I found the solution that resizes my Fragment - I added fitsSystemWindows=true in the root element of my Activity - but it breaks my statusbar...