Custom Toolbar layout with edit text - android

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>

Related

How to remove the gap of icon when float left in the relative layout?

I want to remove the gap on the left of button_history but it's not working.
i have tried to use android:layout_alignParentStart="true" to align the button_history to the left but still not worked.
The icon on the left has a gap.
Below is my xml code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fireTopLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorDrowzyBg"
android:keepScreenOn="true"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/action_bar"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_close"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:background="#drawable/ic_close" />
<Button
android:id="#+id/button_history"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:background="#drawable/ic_list" />
<TextView
android:id="#+id/text_view_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="00:00"
android:textColor="#android:color/black"
android:textSize="30sp" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</RelativeLayout>
I expect it have no gap on the left button_history
The problem is due to the fact that the default behavior of Toolbars is to add white space between the border and where the RelativeLayout begins. To fix this add the following to your Toolbar.
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
By default toolbar add some white space so, to ignore or remove these white space we can add these line of code in toolbar in xml layout app:contentInsetLeft="0dp" and
app:contentInsetStart="0dp"
Full Code Is:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fireTopLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorDrowzyBg"
android:keepScreenOn="true"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/action_bar"
android:elevation="4dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_close"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:background="#drawable/ic_close" />
<Button
android:id="#+id/button_history"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:background="#drawable/ic_list" />
<TextView
android:id="#+id/text_view_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="00:00"
android:textColor="#android:color/black"
android:textSize="30sp" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</RelativeLayout>
Apply this attribute to your toolbar:
app:contentInsetStart="0dp"

Why title is not centered in toolbar?

I am trying to add customized toolbar i want cart badge count so i added the relative layout to toolbar widget, when i didn't added relative layout in toolbar the title appeared in center but now removing relative layout causes problem in adding badge textview on cart, can anybody suggest what to do in this situation?
Toolbar.xml
<android.support.v7.widget.Toolbar
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/mytoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
app:contentInsetLeft="0dp"
android:clipToPadding="false"
app:contentInsetStartWithNavigation="0dp"
app:contentInsetEndWithActions="0dp"
android:background="#color/header">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/displaytexttoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_margin="#dimen/activity_vertical_margin"
android:text="TEXT_VIEW"
android:textColor="#color/white" />
<RelativeLayout
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/cart_imagetoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="end"
android:layout_margin="#dimen/activity_vertical_margin"
android:src="#drawable/cart_mobile_white" />
<TextView
android:id="#+id/tvBadge"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:background="#drawable/cart_circle_mobile"
android:gravity="center"
android:textColor="#color/white"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
It has to do with your layout_margin. Try the below:
<TextView
android:id="#+id/displaytexttoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft|Right="?attr/actionBarSize"
android:text="TEXT_VIEW"
android:textColor="#color/white" />
Default value of the contentInsetStart (left padding in toolbar) is 16dp.
Change it to
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
Try this code:
use a Framelayout instead of RelativeLayout and apply android:gravity="center" for the Title
<android.support.v7.widget.Toolbar 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/mytoolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
android:theme="#style/ThemeToolbar"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/displaytexttoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/activity_vertical_margin"
android:gravity="center"
android:text="TEXT_VIEW"
android:textColor="#color/color_black" />
<ImageView
android:id="#+id/cart_imagetoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="end"
android:layout_margin="#dimen/activity_vertical_margin"
android:src="#mipmap/ic_launcher" />
<ImageView
android:id="#+id/tvBadge"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:gravity="center"
android:src="#mipmap/ic_launcher"
android:textColor="#color/color_black"
android:visibility="visible" />
</FrameLayout>
</android.support.v7.widget.Toolbar>
Output

How to get rid of extra space next to hamburger icon navigation drawer

I Have the layout shown as in this image and this is how my xml 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"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
tools:context="pulsesecure.net.securewebbrowser.HomeActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:theme="#style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:paddingTop="10dp"
android:paddingBottom="5dp"
app:popupTheme="#style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/frag_toolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="#+id/frag_title"
android:layout_width="0dp"
android:layout_weight="9"
android:layout_height="match_parent"
android:textColor="#android:color/white"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<ImageButton
android:id="#+id/add_tab_btn"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:src="#mipmap/ic_add_white_24dp"
android:background="#color/colorPrimaryDark"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/urlBar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="horizontal"
android:visibility="gone"
android:background="#color/colorPrimaryDark"
android:focusableInTouchMode="true"
>
<EditText
android:id="#+id/searchET"
android:layout_width="0dp"
android:layout_weight="9"
android:layout_height="match_parent"
android:textColor="#android:color/darker_gray"
android:layout_gravity="center"
android:imeOptions="actionGo"
android:singleLine="true"
android:hint="#string/hint_url"
android:selectAllOnFocus="true"
android:background="#drawable/rounded_edit_text"
/>
<ImageButton
android:id="#+id/delete_url"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:src="#mipmap/ic_clear_white_24dp"
android:background="#color/colorPrimaryDark"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/select_url_bar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="horizontal"
android:visibility="gone"
android:background="#color/colorPrimaryDark"
android:focusableInTouchMode="true"
>
<TextView
android:id="#+id/url_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:text="text view"
android:clickable="true"
android:singleLine="true"
android:gravity="center_vertical"
android:textColor="#android:color/black"
style="#style/PSFont"
android:background="#drawable/rounded_edit_text"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<ProgressBar
android:id="#+id/page_load_progress"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:progressTint="#color/colorAccent"
android:visibility="invisible"
/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_home" />
</android.support.design.widget.CoordinatorLayout>
I need to get rid of the space between hamburger icon and the Edittext (highlighted with orange arrow). I tried padding and inset, but no luck so far. Can someone give me pointers on this ? Thank you.
My Bad , I should have searched harder :
all I had to do was :
app:contentInsetStartWithNavigation="0dp" in my Toolbar layout.
Remove large padding after hamburger (menu) icon in Android Toolbar?
Try to add below attribute in your <android.support.v7.widget.Toolbar>.
app:contentInsetStartWithNavigation="0dp"
Adding this will work & if it is still not working then just add these two attributes as well
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"

Coordinator Behavior ImageView

I'm having some trouble with my CoordinatorLayout. When I scroll up I want the imageview to disappear completely.
This is an example of view and after i scroll up
http://imgur.com/KI8kouG
planet_main.xml
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimary"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/ctlLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:titleEnabled="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="64dp"
android:layout_marginRight="64dp"
android:layout_marginTop="32dp"
android:fitsSystemWindows="true"
android:orientation="vertical"
app:layout_collapseMode="parallax"
>
<ImageView
android:id="#+id/userAvatar"
android:layout_width="#dimen/fab_large"
android:layout_height="#dimen/fab_large"
android:layout_gravity="center_horizontal"
android:src="#drawable/pl_alderaan"
android:padding="2dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="#+id/userLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_horizontal"
android:maxLines="1"
android:textSize="36sp"
android:text="Header"
android:textColor="#color/white"/>
<TextView
android:id="#+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_horizontal"
android:maxLines="1"
android:textSize="16sp"
android:textStyle="bold"
android:text="Subheader"
android:textColor="#color/white"
/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</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:background="#drawable/card"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_gravity="fill_vertical">
<TextView
android:id="#+id/txtDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textColor="#color/text"
android:gravity="center"
android:text="#string/lorum"
android:textSize="14sp"
android:layout_margin="10dp" />
</android.support.v4.widget.NestedScrollView>
I've also attempted to implement a custom behavior after finding a few examples on, especially this GitHub app example byGitskarios since our layouts are similar but it does not fix my issue. I also read Here that it may not be getting called due to it not being a direct child. How do I keep my layout and fade/hide the imageview?
The easy method is to use app:contentScrim="#color/your_toolbar_color" on the CollapsingToolbarLayout. Technically this won't get rid of the image, it will just cover it with your toolbar's color again, but it will appear to fade out and in.

Soft keyboard pushing toolbar into top status bar

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.

Categories

Resources