I have the recycler view scroll over the top of the toolbar but the toolbar items (eg. home button) are not clickable.
My layout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/primary">
<include
android:id="#id/toolbar_feed"
layout="#layout/toolbar_feed"/>
// Inside viewPager is recycler view which scroll over the toolbar
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:id="#+id/navigation_bottom_layout"
layout="#layout/bottom_navigation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
My only problem is that toolbar home button is not clickable because it is behind viewPager layer. It can work with playing translationZ but it only support API21+. So, you guys have an idea to make this work?
Change the order in which you add the views in their parent.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/primary">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include
android:id="#id/toolbar_feed"
layout="#layout/toolbar_feed"/>
<include
android:id="#+id/navigation_bottom_layout"
layout="#layout/bottom_navigation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Related
I have a persistent bottom sheet inside coordinate layout. I have set bottomsheethideable = true and implemented BottomSheetBehaviour callbacks. Currently, bottom sheet opens in the collapsed mode and when I am scrolling recylerview inside view pager of bottomsheet . BottomSheet also scrolled up that is the default behavior of bottomsheet. I want to keep bottom sheet in collapsed stated utill i reached at last position of recylerview and after then bottomsheet should scroll up and required opposite behavior too.
Inside bottom sheet, there is a view pager. Here is XML file code :
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/ll_bottom"
android:background="#android:color/transparent">
<RelativeLayout
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:transitionName="app_bar_layout">
<com.appstreet.pixylz.view.ASToolbar
android:id="#+id/tb_top"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:minHeight="?attr/actionBarSize"
app:theme="#style/AppTheme.ActionBarTheme" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_below="#id/app_bar_layout" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<include
android:id="#+id/bottom_bar"
layout="#layout/layout_browser_bottom"
android:layout_width="match_parent"
android:layout_height="#dimen/bar_ht_with_9path_shadow"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:background="#color/colorPrimary"
app:tabGravity="fill"
app:tabIndicatorColor="#color/colorAccent"
app:tabIndicatorHeight="3dp"
app:tabMode="fixed" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Someone suggested to create custom BottomSheetBehaviour and disable TouchEvents using return false onTouchEvent and onInterceptTouchEvent inside CustomBottomSheetBehaviour. Using this RecylerView Scrolled and BottomSheet also stayed on collapsed position but on end of recylerview scroll. BottomSheet doesn't dragged Up or Down even sliding outside of recylerview bottomsheet is not dragging.
Anyone can help or suggest solution? Thanks.
I have a requirement where I need to code a screen which has a info view in top and view pager with two tabs in the bottom. View pager has two tabs with Recycler View inside it.
The View pager should stick whenever the user scrolls up and then the recycler view inside it should start scrolling. To achieve this I created two separate fragments for top part and bottom part and wrote the xml like this.
<com.citi.mobile.dashboard.views.StickyScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/core_color_FFFFFF_white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/title_id"
layout="#layout/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<FrameLayout
android:id="#+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="sticky">
</FrameLayout>
</LinearLayout>
Inside the the bottom container I have a View Pager.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="#+id/TransTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabIndicatorColor="#color/core_color_0077bb_blue"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/core_color_0077bb_blue"
app:tabTextAppearance="#style/ledgerTabLayoutTextAppearance"
app:tabTextColor="#color/core_color_666666_grey"
custom:typefaceName="Roboto-Medium" />
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/transaction_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
This has two tabs and each has a recycler view inside this. When I run this the parent scrollview stops working and only the recyclerview scrolling works.
Try adding android:nestedScrollingEnabled="false" to the recyclerview in your xml.
View pager ScreenShot
Vertical View Pager
First Fragment
Second Fragment
Collapsing Toolbar
Image View
Tab Layout
View Pager
Grid Fragment
Second Fragment
Recycler View(Main)
Recycler View
Map Fragment
When i scroll (Main)recycler view Collapsing toolbar should expand and collapse and after vertical view pager should scroll.
But in my code (main)Recycler view not scrolling properly and collapsing toolbar not working properly.
Xml:
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_collapseMode="none">
<TextView... />
<ProfileView... />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/fragment_snip_details_2view"
android:layout_width="match_parent"
android:layout_height="#dimen/_40sdp"
android:background="#color/colorAccent"
android:minHeight="#dimen/_40sdp"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
<TabLayout...>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="#+id/fragment_snip_details_2_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
wrap your viewpager inside a NestedScrollView instead of a LinearLayout and then set the layout_behavior to appbar_scrolling_view for both the NestedScrollView and the ViewPager. Took me forever but I found that this worked for me.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<com.example.ashleighwilson.schoolscheduler.views.CustomViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</com.example.ashleighwilson.schoolscheduler.views.CustomViewPager>
</android.support.v4.widget.NestedScrollView>
also be sure to set fillViewport to true in the NestedScrollView and make sure the width and height is set to match parent. This is important.
I have a layout similar to the one shown in image below.
Layout Explained
<ScrollView>
<LinearLayout>
...
</LinearLayout>
<ViewPager>
</ScrollView>
ViewPager has a height equal to the height of screen below ActionBar.
While scrolling, when half of the viewPager is visible.. Vertical scroll of RecylerView of fragment in ViewPager interferes with the main scroll of ScrollView.
I want a solution that makes sure the scroll of RecyclerView inside viewpager is disabled untill the viewpager is fully visible.
Main.xml
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/footer"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginLeft="#dimen/secondary_margin"
android:layout_marginRight="#dimen/secondary_margin"
android:id="#+id/scroll_view">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/home_deals_slider" />
<include layout="#layout/top_selling_slider" />
...
<TabLayout>
<android.support.v4.view.ViewPager
android:id="#+id/fragments_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/fragments_view_pager_tab" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Fragment.xml
<FrameLayout 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" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/staggered_grid_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</RelativeLayout>
...
I have the following Layout and I want to hide the LinearLayout "cv" and its included child behind the toolbar.
I searched for it and found a lot of Examples to hide the toolbar, but none of them showed me to hide any other View than the toolbar (example). Is there a possibility to do it with a CoordinatorLayout?
<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"
tools:context="de.app.activities.AccountDetail">
<include
android:id="#+id/app_bar"
layout="#layout/app_bar" />
<LinearLayout
android:id="#+id/cv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/app_bar">
<include layout="#layout/single_account" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/cv">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>