I have gone through at least ten similar SO questions and nothing seems to work.
I have a simple relative layout with a toolbar, text views, edit text, etc (see xml below).
When edit text is focused I need the soft keyboard to push my layout up but under the toolbar (i.e. toolbar is pinned) but instead the keyboard pushes the entire layout up, toolbar included?
I have tried adjustPan, adjustResize, scrollviews, etc with no success, any help with this would be appreciated.
layout xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.Test">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:id="#+id/appbar_layout"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/appbar_layout">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_title"
android:textSize="25dp"
android:textColor="#color/colorPrimaryDark"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/iv"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/tv_date"
android:textSize="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/iv"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tv_title"/>
<ImageView
android:id="#+id/iv"
android:layout_marginRight="-6dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentRight="true"
android:maxHeight="150dp"
/>
<TextView
android:id="#+id/tv_description"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/iv"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#color/colorPrimaryDark"/>
<RatingBar
android:id="#+id/rb"
style="?android:attr/ratingBarStyle"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_description"
android:numStars="5" />
<View
android:id="#+id/view"
android:layout_below="#+id/rb"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="1dp"
android:visibility="visible"
android:background="#color/colorPrimary"/>
<EditText
android:id="#+id/et"
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="#dimen/activity_horizontal_margin"
android:layout_below="#+id/view"
android:gravity="top"
android:background="#android:color/transparent"
/>
<Button
android:id="#+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textColorPrimary"
android:textSize="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I use this code on the onCreateView of my fragment, it works fine.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Use CollapsingToolbarLayout
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
and make sure you add app:layout_collapseMode="pin" flag to your Toolbar in your layout.xml.
Related
I have AppBarLayout with CollapsingToolbarLayout. Inside I have an ImageView as a background, and ConstraintLayout with TextViews. Expected behaviour on scroll: the AppBarLayout shrinks just enough so that the the whole ConstraintLayout is still visible. Unfortunately what happens for me, is that the ConstraintLayout moves up and is out of view.
Here's what I want it to look like:
Before scroll
after scroll
Instead, this is what I have right now:
Before scroll
After scroll
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="262dp"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#00FFFFFF"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
android:src="#drawable/img_dashboard"/>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="140dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:layout_gravity="bottom|center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#id/featured_main_text"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Offline"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:layout_marginStart="28dp"
android:layout_marginEnd="12dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2 hrs ago"
android:textColor="#FFFFFF"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/featured_main_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="John Smith"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:layout_marginStart="28dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Place Holder"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:layout_marginStart="28dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Place Holder"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:layout_marginStart="28dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_scrolling" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I looked at CollapsingToolbarLayout tutorials, but can't find anything where it just shrinks instead of actually collapsing into a toolbar.
All what you have written in your code will not work out of box. If you want to achieve the result how it shows in your expected screenshot you need to write CoordinatorLayout.Behavior for each View/viewGroup that hold your items. And set it to your View/ViewGroup.
I have some issues with parallax for android, where I currently have an image on top (with text content in the center) and a button on the top right.
Now as I scroll, I want the text and button to remain fixed on screen. As I scroll past the appbar (toolbar), the toolbar should be fixed to the top and the button should be on top right of it, fixed to it , while the rest of the content stays scrollable.
Here's my code (without parallax), any clue how i can achieve this ?
<?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:id="#+id/cl_root_view"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
<LinearLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Toolbar"
android:background="#color/white"
android:contentInsetStart="5dp"
android:contentInsetLeft="5dp"
android:contentInsetEnd="5dp"
android:contentInsetRight="5dp"
app:contentInsetEnd="5dp"
app:contentInsetLeft="5dp"
app:contentInsetRight="5dp"
app:contentInsetStart="5dp"
app:titleTextAppearance="#style/Toolbar.TitleText">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/toolbar_title"
style="#style/Toolbar.AltTitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:drawableStart="#drawable/ic_dots"
android:gravity="center_vertical" />
<ImageButton
android:id="#+id/my_button"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="#+id/toolbar_title"
android:layout_marginEnd="20dp"
android:background="#drawable/ic_my_button"
android:tint="#color/black" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:id="#+id/roomsTitle"
style="#style/Headline2LeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toStartOf="#+id/btnMore"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="#string/meeting_rooms"
android:textAppearance="#style/TextAppearance.Text.Chronicle"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/btnMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/transparent"
android:fontFamily="sans-serif"
android:letterSpacing="0.02"
android:lineSpacingExtra="2sp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="#string/all_rooms"
android:textColor="#color/reddish"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v4.view.ViewPager
android:id="#+id/roomViewPager"
android:layout_width="match_parent"
android:layout_height="400dp"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingStart="15dp"
android:paddingTop="16dp"
android:paddingEnd="15dp"
android:paddingBottom="45dp"
app:layout_constraintTop_toBottomOf="#id/roomsTitle" />
<RelativeLayout
android:id="#+id/register_a_visitor_container"
android:layout_width="0dp"
android:layout_height="75dp"
android:layout_margin="5dp"
android:layout_marginTop="35dp"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/roomViewPager">
<ImageView
android:id="#+id/register_visitor_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:tint="#color/reddish"
android:src="#drawable/ic_register_visitor_icon"
/>
<TextView
android:id="#+id/register_a_visitor_button"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:letterSpacing="0.01"
android:layout_marginStart="16dp"
android:layout_toEndOf="#+id/register_visitor_icon"
android:lineSpacingExtra="8sp"
android:text="#string/register_a_visitor"
android:textAllCaps="false"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<ImageView
android:id="#+id/reset_password_chevron"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:tint="#color/brownish_grey"
android:background="#drawable/ic_baseline_chevron_right_24px"
/>
</RelativeLayout>
<!-- TODO work on it after MVP -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/container">
<TextView
android:id="#+id/upcoming_events"
style="#style/Headline3LeftGrey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="25dp"
android:text="#string/upcoming_events" />
<android.support.v7.widget.RecyclerView
android:id="#+id/event_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/upcoming_events"
android:background="#color/black"
tools:listitem="#layout/item_repo_view" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
As you can see from the above layout. I want to add an image (and add the my_button on top right of that image) that is above the toolbar and scrolls off the screen as you scroll up while my button stays in its place until the toolbar gets on top ,after which the toolbar is affixed to the top as you scroll further up, unless you scroll down and the image is visible again and the button is no more fixed.
Please let me know if this is confusing,I will try to explain it better with diagrams if possible.
Any examples will be helpful! thanks!
Please refer below code, i have made something like you.
<?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:id="#+id/view_profile_parent_layout"
android:background="#color/splash_bg_color"
tools:context=".view_profile.ViewProfileActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_barLayout"
android:layout_width="match_parent"
android:layout_height="#dimen/view_profile_profile_app_bar_height"
android:elevation="#dimen/view_profile_app_bar_elevation"
android:theme="#style/ThemeOverlay.AppCompat.Light">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:titleEnabled="false"
android:fitsSystemWindows="true"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/view_profile_imageView"
android:layout_width="#dimen/view_profile_profile_width"
android:layout_height="#dimen/view_profile_profile_height"
android:src="#drawable/ic_profile_icon"
android:layout_centerHorizontal="true"
app:civ_border_width="#dimen/view_profile_profile_border_width"
app:civ_border_color="#color/textPrimary"/>
<TextView
android:id="#+id/view_profile_profile_name_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/view_profile_profile_name_margin_top"
android:layout_below="#id/view_profile_imageView"
android:fontFamily="#font/roboto_regular"
android:text=""
android:textSize="#dimen/view_profile_profile_name_text_size"
android:gravity="center"
android:textColor="#color/white"/>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
app:layout_collapseMode="pin"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="#dimen/login_btn_elevation"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="#+id/back_button"
android:layout_width="#dimen/back_btn_layout_w"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<Button
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="#dimen/back_btn_w"
android:layout_height="#dimen/back_btn_w"
android:layout_marginStart="#dimen/default_padding"
android:clickable="false"
android:background="#drawable/ic_arrow_back_white_24dp"
android:elevation="#dimen/login_btn_elevation" />
</LinearLayout>
<TextView
android:id="#+id/nav_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginStart="#dimen/nav_outer_h_space"
android:fontFamily="#font/roboto_regular"
android:text=""
android:gravity="center"
android:textColor="#color/white"
android:textSize="#dimen/title_size" />
<Button
android:id="#+id/edit_button"
android:layout_width="#dimen/back_btn_w"
android:layout_height="#dimen/back_btn_w"
android:layout_gravity="right"
android:layout_centerInParent="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="#dimen/nav_outer_h_space"
android:background="#drawable/edit_white_icon"
android:elevation="#dimen/login_btn_elevation" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Use
app:layout_scrollFlags="exitUntilCollapsed|scroll"
in collapsing layout
app:layout_collapseMode="pin"
in Toolbar
I created a custom layout for toolbar with edittext but it does not fit in toolbar.
I needed toolbar like this
But got this output
I needed full width edittext. Help me to achive this
My XML Code
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:gravity="center"
app:contentInsetStart="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIcon="#drawable/icon_toolbar_back"
app:popupTheme="#style/ThemeOverlay.AppCompat.Dark"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:titleTextAppearance="#style/ToolbarTextAppearance">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imgActionLogo"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:src="#drawable/common_google_signin_btn_icon_dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginLeft="#dimen/_10sdp"
android:layout_marginRight="#dimen/_10sdp"
android:background="#drawable/toolbar_search_bg"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="#dimen/_5sdp"
android:paddingRight="#dimen/_5sdp"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
android:src="#drawable/icon_search" />
<EditText
android:id="#+id/etSearch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/_5sdp"
android:background="#null"
android:editable="false"
android:hint="Search More Products..."
android:textColorHint="#color/text_medium"
android:textSize="#dimen/_10sdp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
I also searched on google but not able to achieve this.
The inner content of the Toolbar will shrink if you use app:navigationIcon and/or menu items.
You can omit app:navigationIcon and menu items and create your own buttons inside Toolbar.
Then setting
<android.support.v7.widget.Toolbar
...
app:contentInsetRight="0dp"
app:contentInsetLeft="0dp">
...
</android.support.v7.widget.Toolbar>
should give you more control of content padding
When you are using toolbar it will add some margin space after menu icon. So you have to add search view below of toolbar with same background color parent and make it fixed if there are any scroll then add that scroll below of search layout. Try this.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:background="?attr/colorPrimary"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:gravity="center"
app:contentInsetStart="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIcon="#drawable/icon_toolbar_back"
app:popupTheme="#style/ThemeOverlay.AppCompat.Dark"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:titleTextAppearance="#style/ToolbarTextAppearance">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imgActionLogo"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:src="#drawable/common_google_signin_btn_icon_dark"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:background="?attr/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginLeft="#dimen/_10sdp"
android:layout_marginRight="#dimen/_10sdp"
android:background="#drawable/toolbar_search_bg"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="#dimen/_5sdp"
android:paddingRight="#dimen/_5sdp"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
android:src="#drawable/icon_search" />
<EditText
android:id="#+id/etSearch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/_5sdp"
android:background="#null"
android:editable="false"
android:hint="Search More Products..."
android:textColorHint="#color/text_medium"
android:textSize="#dimen/_10sdp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
<RelativeLayout 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:id="#+id/create_case_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/lb_background"
tools:context="com.cubesquaretech.lawbuddy.Activity.CreateCaseActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/create_case_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextAppearance="#style/MyToolbar">
<TextView
android:id="#+id/toolbar_title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/colorTextPrimary" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/tab_color_selector"
app:tabIndicatorColor="#color/colorTextPrimary"
app:tabTextColor="#color/colorTextPrimary" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_above="#id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
/>
<RelativeLayout
android:id="#+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="#dimen/view"
android:layout_above="#id/btn_next"
android:background="#color/colorWhite" />
<Button
android:id="#+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#null"
android:text="#string/next"
android:textColor="#color/colorWhite" />
<Button
android:id="#+id/btn_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#null"
android:textColor="#color/colorWhite" />
</RelativeLayout>
</RelativeLayout>
This is the xml code for Activity containing TabLayout and ViewPager
The Buttons are below pager which comes up with softkeyboard when focuses on edittext.
I want that softkeyboard to open without buttons coming up.
I used SoftInuptKeyboard Hide in manifest that works for me.
First time the SoftInuptKeyboard doesnt open when we open it by clicking on
editext then it works fine the buttons don't come up with keyboard.
If I remove the below code from manifest
android:windowSoftInputMode="stateHidden|adjustPan"
then the button goes up with SoftInuptKeyboard
I am using a CollapsingToolbarLayout for a collapsing tool bar and it works for the most part. When you start scrolling on any part of the page besides the RecyclerView it will scroll fine and the toolbar will collapse like it should. However when you do start scrolling on the RecyclerView it doesn't collapse the tool bar and doesn't look the best.
I've tried a lot of different solutions I've found online and none have seemed to help. I'm using appcompat-v7:23.2.1. Here's what the layout file looks like:
<?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">
<android.support.design.widget.AppBarLayout
android:id="#+id/movie_detail_app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/movie_detail_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/movie_detail_backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:contentDescription="#string/cd_backdrop"/>
<android.support.v7.widget.Toolbar
android:id="#+id/movie_detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!-- Movie Content here -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:padding="16dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/movie_detail_out_yet_layout"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_width="20dp"
android:layout_height="20dp"
tools:background="#drawable/green_square">
<ImageView
android:id="#+id/movie_detail_out_yet_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:src="#drawable/ic_checkmark"/>
</RelativeLayout>
<TextView
android:layout_toRightOf="#+id/movie_detail_out_yet_layout"
android:layout_toEndOf="#+id/movie_detail_out_yet_layout"
android:id="#+id/movie_detail_release_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/textAppearanceMedium"
tools:text="March 21, 2016"/>
<TextView
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:id="#+id/movie_detail_mpaa_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:text="PG-13"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<TextView
android:layout_marginTop="16dp"
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/h_plot"/>
<TextView
android:layout_marginTop="5dp"
android:id="#+id/movie_detail_plot"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="16dp"
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/h_ratings"/>
<TextView
android:id="#+id/movie_detail_no_ratings_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/unknown"
android:visibility="gone"/>
<LinearLayout
android:orientation="horizontal"
android:id="#+id/movie_detail_rating_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Critics Section -->
<LinearLayout
android:layout_weight="0.5"
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/movie_detail_critics_rating_box"
android:layout_marginTop="5dp"
tools:background="#drawable/orange_square"
tools:text="6.7"
android:textColor="#android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_gravity="center_vertical"
android:id="#+id/movie_detail_critics_rating_tv"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/textAppearanceMedium"
android:text="#string/critics_rating"/>
</LinearLayout>
<!-- Audience Section -->
<LinearLayout
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/movie_detail_audience_rating_box"
android:layout_marginTop="5dp"
tools:background="#drawable/orange_square"
tools:text="6.7"
android:textColor="#android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/textAppearanceMedium"
android:text="#string/audience_rating"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginTop="16dp"
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/h_cast"/>
<TextView
android:id="#+id/movie_detail_no_cast_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
style="?android:textAppearanceMedium"
android:text="#string/unknown"
android:visibility="visible"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/movie_detail_cast_member_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:visibility="gone"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
For the RecyclerView, I set it to have a LinearLayoutManager and to my custom adapter. Any help would be great, it's been a couple weeks and I still haven't been able to figure this out.
Edit: It appears to only happen when scrolling up. If the tool bar is collapsed and I scroll down, it does expand like it should. However, as before, when scrolling up it doesn't seem to work.