CoordinatorLayout with RecyclerView and bottom-pinned EditText

I’m developing a chat screen. It consists of CollapsingToolbarLayout for user profile image, RecyclerView for messages list and an edit box to send messages. I can’t figure out if it’s possible to pin edit box to the bottom screen and prevent it from scrolling with the rest of the screen?

I achieved almost what I want if I wrap CoordinatorLayout in a vertical LinearLayout and put EditText outside of CoordinatorLayout. However in this case keyboard behavior is detached from RecyclerView – it doesn’t scroll up/down when you open keyboard.

  • Detect 'home button pressed' event in android service displaying a UI (similar to facebook chatheads)
  • MainActivity has leaked ServiceConnection android.speech.SpeechRecognizer$Connection@414ee400 that was originally bound here
  • Syncadapter onPerformSync being called twice the first time
  • Spinner is not working in android
  • “Possible overdraw: Root element paints background ”
  • Warning in Google Map
  • If I try to put EditText inside CoordinatorLayout it scrolls out of screen, I don’t know if there is any special Behavior I need to set for it

    My Layout

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
       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/keyboard_listener"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="vertical"
    >
    
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >
    
        <RecyclerView
           android:id="@android:id/list"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:clickable="true"
           android:clipToPadding="false"
           android:focusableInTouchMode="true"
           android:paddingBottom="20dp"
           android:scrollbarStyle="outsideOverlay"
           android:scrollbars="vertical"
           android:transcriptMode="normal"
           app:layout_behavior="@string/appbar_scrolling_view_behavior"
           />
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            >
    
            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/screen_toolbar_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
                app:titleEnabled="false"
                >
    
                <FrameLayout
                    android:id="@+id/toolbar_fragment_container"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    />
    
                <Toolbar
                    android:id="@+id/screen_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@android:color/transparent"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:layout_collapseMode="pin"
                    />
    
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>
    
            <EditText
                android:id="@+id/messageEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:hint="@string/send_hint"
                android:inputType="textCapSentences|textMultiLine"
                android:maxLength="2000"
                android:maxLines="4"
                android:padding="10dp"
                android:textSize="14sp"/>
    
    </LinearLayout>
    

    Related posts:

    android genymotion vs emulator
    Custom background color for selected item with &ldquo;activatedBackgroundIndicator&rdquo; Na...
    ProGuard didnt compile with Joda Time used in Windows
    Android ConstraintLayout generates absolute values
    Pre-guess size of Bitmap from the actual Uri, before scale-loading
    I&#039;m stuck installing Crashlytics for Android using Eclipse
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.