How to put a custom view/layout pinned in CollapsingToolbarLayout ? - android

Background
The support/design library allows to have a nice resize-as-you-scroll effect, using AppBarLayout and CollapsingToolbarLayout :
http://material-design.storage.googleapis.com/publish/material_v_3/material_ext_publish/0B0NGgBg38lWWcFhaV1hiSlB4aFU/patterns-scrollingtech-scrolling-070801_Flexible_Space_xhdpi_003.webm
The problem
All examples I've seen are of Toolbar being the one pinned as you scroll.
What I'm trying to achieve is that a custom view will be pinned, in a size of a toolbar, while the content above it (some other views) will shrink as you scroll.
Something like that:
Thing is, no matter what I try, something doesn't work this way. Sometimes the content of the toolbar-replacement gets truncated, sometimes it doesn't get pinned, etc...
What I've tried
Since for some reason the Toolbar is the only thing that seems to work well with the app:layout_collapseMode="pin" attribute, I tried to either put views in it, or put views with it.
Here's the current XML layout of what I've tried:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:background="#fff"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:padding="0px"
app:contentScrim="#eeeeee"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="">
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginBottom="0px"
android:background="#33ff0000"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/titleTextView"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="#33ffff00"
android:gravity="center"
android:text="someText"
android:textColor="#000"/>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_scrolling"/>
</android.support.design.widget.CoordinatorLayout>
Sadly, even though the layout editor shows that it looks ok, what I actually see is this truncated text for the toolbar-replacement view:
I also tried using layout_anchor, as shown on a sample of how to use it (here), but even then, the view that is supposed to replace the toolbar seems to overlap the content that's supposed to be below it and the one above it, and even the view that's above it have some space below it that isn't supposed to be there:
And here's the XML layout of this try:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
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:background="#3300ff00"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<FrameLayout
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:orientation="vertical"
android:paddingBottom="?attr/actionBarSize"
app:layout_collapseMode="none">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="need to be right above 'someText'"
android:textColor="#ff000000"/>
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:behavior_overlapTop="0dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lorem"/>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#33ff0000"
app:layout_anchor="#id/title"
app:layout_anchorGravity="bottom"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:title="">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="someText"
android:textColor="#android:color/white"
android:textSize="20sp"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CoordinatorLayout>
The questions
How can I put custom views so that the toolbar content will stay between the bottom and upper areas, not overlapping any of them, and have the area above the toolbar to shrink as you scroll ?

For now, I'm using a workaround for this issue, by using padding that will prevent the overlapping of the views. I still don't get why the views overlap, but this helps against it.
The problem with this, is that now the toolbar doesn't have a shadow when I scroll enough so that it's the only thing that appears at the top.
Here's a sample XML layout, in case anyone wants to try:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
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:background="#3300ff00"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|center_horizontal"
android:orientation="vertical"
android:paddingBottom="24dp"
app:layout_collapseMode="none">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="#f00"/>
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="24dp"
android:scrollbars="none"
app:behavior_overlapTop="0dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lorem"/>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#33ff0000"
app:layout_anchor="#id/title"
app:layout_anchorGravity="bottom"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:title="">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="someText"
android:textColor="#android:color/white"
android:textSize="20sp"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CoordinatorLayout>

Related

I am facing issue while setting the top of nested scrollview at half of total height during loading of activity

I want that when my activity will load, the top of scrollview will be at half of the screen height (like img_1.png). But I am getting it at the bottom (like img_2.png). And it must be scrollable (like img_3.png, img_4.png, img_5.png in drive link) up and down during scrolling.
And here is my code.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Main4Activity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="6dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/col_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?android:attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:scrollIndicators="bottom"
android:background="#android:color/black"
app:layout_collapseMode="parallax"/>
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="#drawable/tab_selector"
app:tabGravity="center"
android:layout_gravity="bottom"
app:tabIndicatorHeight="0dp"/>
</android.support.design.widget.CollapsingToolbarLayout>
<View
android:id="#+id/view_below_image"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/colorPrimary"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="About me"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/colorPrimary" />
<TextView
android:layout_width="match_parent"
android:layout_height="650dp"
android:text="Description"
android:textSize="50dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Thanks for help in advance.
https://drive.google.com/open?id=1hDELP83a3YV1p1GxnfG0IpLmfwQFKWfr
Same issue with me.
I just want the AppBarLayout height as MATCH_PARENT.
But when I open the activity for the first time, I need it's bottom to the half of the screen. And after that on scrolling, the AppBarLayout will expand like IMAGE 3, 4, 5 uploaded by #Abhinav.
You have define
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="6dp">
Instead of that give some static value so you will get your result
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="6dp">

Donot want to expand Collapsing toolbar

I am using a collapsing Toolbar. If I start a specific Fragment I want to collapse the Toolbar so it behaves like a "normal" one and that the user can not expand it by himself. Also I want only the views ion nested scrollview to scroll and not the toolbar when i collapse. Here is my layout which I use for my Toolbar:
<?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/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/collapsing_height"
android:fillViewport="true"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:id="#+id/past_upcoming_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#efeded"
android:fitsSystemWindows="true"
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<TextView
android:id="#+id/upcoming_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:padding="#dimen/spacing_normal_8dp"
android:text="#string/upcoming_appointments"
android:textSize="#dimen/text_size18sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/upcoming_heading">
<android.support.v7.widget.RecyclerView
android:id="#+id/upcoming_appointments_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal" />
<TextView
android:id="#+id/no_upcoming_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/no_upcoming_appointment"
android:textSize="#dimen/text_size18sp" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/past_appointments"
android:textSize="#dimen/text_size18sp" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#efeded"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/past_appointments_recycle_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I have used AppBarLayout.setExpanded(false). It initially shows collapsed, but when I expand back it expands.
I have also used
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
lp.height = (int) getResources().getDimension(R.dimen.collapsing_height);
This doesnot stick toolbar to the top. it scrolls up with nested scroll view. Please help.
Thanks in advance

Collapsing toolbar issue with RecyclerView

I have a CollapsingToolbarLayout in layout, below that I have placed a RecyclerView. it works perfect and the parallax effects comes smoothly when the RecyclerView scrolls, but the issue, is suppose if the RecyclerView has less items and there is nothing to scroll, still it scolls and an empty space shows at the bottom. what my requirment is it shouldn't scroll if the RecyclerView can accomodate all the views in the visible screen, is there any way to do this ?
layout
<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/container_id"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bg_color"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
toolbar.xml
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
app:layout_scrollFlags="scroll"
app:layout_collapseMode="parallax"
android:layout_below="#+id/toolbar"
android:minHeight="250dp"
android:layout_height="300dp"
android:layout_width="match_parent"/>
<android.support.v7.widget.Toolbar
app:layout_collapseMode="pin"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:layout_gravity="top"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ToggleButton
android:layout_centerVertical="true"
android:layout_margin="#dimen/dimen_xs"
android:layout_width="20dp"
android:layout_height="20dp"
android:gravity="center"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:textOff=""
android:textOn=""/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

collapse CollapsingToolbarLayout COMPLETELY

I use CollapsingToolbarLayout in an AppBarLayout only for its parallax effect while scrolling, so I need to collapse the layout completely. I mean set its height to zero after scrolling down. I set the layout minHeight to 0dp but doesn't work, and still have some part of layout visible.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="40dp"
android:paddingRight="40dp"
android:paddingLeft="40dp"
android:background="#e91e63"
android:fitsSystemWindows="true"
android:minHeight="0dp"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="0dp"
android:fitsSystemWindows="true"
app:titleEnabled="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/index_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/suitcase"
android:padding="20dp"
android:background="#drawable/index_page_icon_bg"
android:layout_margin="5dp"
app:layout_collapseMode="parallax"/>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:minHeight="0dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
General Rule: If you think this is not a good Q, declare at comments then do whatever you like!
Change the AppBarLayout like this .
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e91e63"
android:fitsSystemWindows="true"
android:minHeight="0dp"
android:theme="#style/AppTheme.AppBarOverlay">
an the ImageView will be like this .
<LinearLayout
android:paddingTop="40dp"
android:paddingRight="40dp"
android:paddingLeft="40dp"
android:scaleType="fitXY"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/index_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/suitcase"
android:padding="20dp"
android:background="#drawable/index_page_icon_bg"
android:layout_margin="5dp" />
</LinearLayout>
The problem was, you make a padding top in the AppBarLayout , so when it collapse it still make the 40dp padding , so the layout can't make Full collapse.

RecyclerView wrapped inside CoordinatorLayout not resized when keyboard opens

Activity layout xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:scaleType="centerCrop"
android:src="#drawable/hospital_logo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="******* ************* ********** ************"
android:textSize="18sp"
android:textColor="#android:color/black"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="***************************"
android:textSize="18sp"
android:textColor="#android:color/black"
android:textStyle="bold"/>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Here I am using CoordinatorLayout with CollapsingToolbarBar and ViewPager.
I have adding two fragment inside ViewPager with layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</LinearLayout>
The cell of recycler_view contains EditText. When I selects EditText SoftKeyboard opens but EditText hides behind keyboard.
I have added following flags to activity:
android:windowSoftInputMode="adjustResize"
I am using 23.1.1 appcompat version of RecyclerView.
When I replace CoordinatorLayout with LinearLayout RecyclerView is getting resize to show last element correctly. So I thinks it is the issue with Coordinator layout.
I went through following issues https://code.google.com/p/android/issues/detail?id=176406 and https://code.google.com/p/android/issues/detail?id=176187 but it is nor related to this bug. Let me know if I can apply some path to solve this.
Waiting for reply. Thanks.
Let me know if more details needed.
Had a very similar issue and was able to fix it by using android:windowSoftInputMode="adjustPan"

Categories

Resources