Reputation: 681
I just started working with CoordinatorLayout
and AppBar. I have a layout activity_home.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.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|enterAlways">
<AutoCompleteTextView
android:id="@+id/ac_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:focusable="true"
android:hint="@string/search"
android:imeOptions="actionSearch"
android:singleLine="true"
android:visibility="gone"/>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="@+id/layout_search_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@color/white"
android:orientation="horizontal"
android:paddingStart="@dimen/_6sdp"
android:paddingEnd="@dimen/_6sdp">
<CheckBox
android:id="@+id/cb_search_deals"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/_6sdp"
android:layout_weight="0.45"
android:button="@drawable/checkbox_button"
android:checked="true"
android:paddingStart="@dimen/_8sdp"
android:text="@string/Search_for_Deals"
android:textSize="13sp"/>
<View
android:layout_width="0.25dp"
android:layout_height="match_parent"
android:layout_weight="0.015"
android:background="@color/grey"/>
<CheckBox
android:id="@+id/cb_search_business"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginStart="@dimen/_12sdp"
android:layout_weight="0.50"
android:button="@drawable/checkbox_button"
android:paddingStart="@dimen/_8sdp"
android:text="@string/Search_for_Business"
android:textSize="13sp"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_search_results"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="start|center_vertical"
android:background="@color/red"
android:gravity="start|center_vertical">
<TextView
android:id="@+id/tv_search_results"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/iv_filter_results"
android:paddingStart="15dp"
android:text="Showing 10 Results"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="normal"/>
<ImageView
android:id="@+id/iv_filter_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="@drawable/ic_filter"/>
</RelativeLayout>
<ListView
android:id="@+id/lv_search_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:divider="@color/white"
android:dividerHeight="0dp"
android:scrollbars="none"
android:visibility="visible"/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/_12sdp"
android:paddingEnd="@dimen/_12sdp"
android:scrollbars="none"
android:background="@color/red"
app:tabTextColor="@color/tab_text_color"
app:tabIndicatorColor="@color/white"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/white"
app:tabTextAppearance="@android:style/TextAppearance.DeviceDefault.Small" />
<ImageView
android:layout_width="match_parent"
android:layout_height="48dp"
android:src="@drawable/tabs_overlay" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
<android.support.v4.view.ViewPager
android:id="@+id/home_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="locale"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<include layout="@layout/layout_navigation"/>
<include layout="@layout/layout_filter"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
ViewPager
with id=home_viewpager
is the handling tablayout fragments.
It's working fine only on Lollipop because in code i have setted listview.setNestedScrollEnabed(true)
but its NOT working on 4.2.2 also the first fragment of viewpager (listview with header) is getting cut off from bottom i.e Complete screen content is not shown.
In my second fragment of viewpager with layout name fragment_top_deals
<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/white"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
<include
layout="@layout/layout_filter_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/banner" />
</android.support.design.widget.AppBarLayout>
<com.app.views.MultiSwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_8sdp"
android:layout_below="@+id/header"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:divider="@null"
android:dividerHeight="@dimen/_8sdp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:text="@string/error_no_data"
android:textSize="24sp"
android:visibility="gone"/>
</FrameLayout>
</com.app.views.MultiSwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
android:indeterminateDrawable="@drawable/custom_progress"
style="?android:attr/progressBarStyle"/>
</RelativeLayout>
the problem is that the the activity_home
coordinator layout + app bar effect is not working instead the CoordinatorLayout
and Appbar of current layout is working fine. This implementation also not working on 4.2.2.
Upvotes: 2
Views: 1150
Reputation: 199805
As you noticed, ListView
only supports nested scrolling (a requirement for AppBarLayout
scrolling support) starting in Lollipop. Prior to that, you must use a view that implements NestedScrollingChild such as RecyclerView or NestedScrollView.
Upvotes: 1