2

I have a RecyclerView that I created along with a header. What happens is that the header is hidden by the keyboard when I try to click on my EditText when I press on the keyboard. The ListView portion of the RecyclerView shows up perfectly but the RecyclerView header does not show up, nor does the action bar when I try to scroll up all the way. I tried to wrap my RecyclerView header in a ScrollView but that didn't seem to work. I know I cannot wrap my RecyclerView in a ScrollView because that would cause nested vertical ScrollViews since RecyclerView already has a built-in ScrollView. Any help would be appreciated. Thanks!

Code:

comments.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:flatui="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fresco="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:id="@+id/comments_coordinator_layout">

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/comments_appbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/layout_comments">

        <LinearLayout
            android:id="@+id/send_message"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal" >

            <com.cengalabs.flatui.views.FlatEditText
                android:id="@+id/write_comment"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="5"
                android:paddingLeft="10dp"
                android:gravity="bottom|left"
                android:cursorVisible="false"
                android:hint="Comment back!"
                android:inputType="textMultiLine"
                flatui:fl_fieldStyle="fl_box"
                android:scrollHorizontally="false" />

            <com.cengalabs.flatui.views.FlatButton
                android:id="@+id/send_comment"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginLeft="5dp"
                android:layout_gravity="center_vertical|center_horizontal"
                android:gravity="center"
                android:text="send"
                flatui:theme="@array/sea"
                flatui:fl_textAppearance="fl_light"/>
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/send_message"
            android:id="@+id/view_comments">
        </android.support.v7.widget.RecyclerView>
    </RelativeLayout>

comments_header.xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fresco="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
    android:id="@+id/view_post"
    android:layout_marginTop="?attr/actionBarSize"
    android:layout_width="match_parent"
    android:paddingRight="5dp"
    android:paddingLeft="5dp"
    android:orientation="horizontal"
    android:layout_height="175dp"
    android:background="#e6e6e6">

    <com.facebook.drawee.view.SimpleDraweeView
        android:layout_marginTop="15dp"
        android:id="@+id/poster_picture"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:layout_marginLeft="10dp"
        fresco:placeholderImage="@mipmap/blank_prof_pic"
        fresco:roundedCornerRadius="5dp"
        fresco:roundAsCircle="true"
        />

    <TextView
        android:layout_marginLeft="5dp"
        android:layout_marginTop="15dp"
        android:layout_toRightOf="@id/poster_picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:id="@+id/poster_name"/>

    <TextView
        android:layout_alignParentRight="true"
        android:layout_marginTop="15dp"
        android:layout_toRightOf="@id/poster_name"
        android:layout_marginLeft="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:id="@+id/post_date"/>

    <TextView
        android:layout_marginLeft="5dp"
        android:layout_toRightOf="@id/poster_picture"
        android:layout_below="@id/poster_name"
        android:textSize="20sp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/view_status" />

</RelativeLayout>

Comments.java:

public void populateComments(long postId) {
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setStackFromEnd(true);
    CommentsRecyclerViewAdapter commentsRecyclerViewAdapter = new CommentsRecyclerViewAdapter(getCommentsHeader(postId), commentsDatasource.getCommentsForPost(postId));
    commentsView.setLayoutManager(llm);
    commentsView.setAdapter(commentsRecyclerViewAdapter);
}

AndroidManifest.xml:

    <activity android:name=".com.tabs.activity.Comments"
        android:label="View Post"
        android:theme="@style/AppTheme.NoActionBar"
        android:configChanges="keyboardHidden"
        android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".com.tabs.activity.news_feed"/>
    </activity>

Images to show what is happening:

Header showing, Edit Text not clicked

Edit Text clicked, header not showing

As you can see If I try to scroll up, the header from the first image is hidden.

user1871869
  • 3,317
  • 13
  • 56
  • 106
  • it's hidden because it doesn't fit on the screen? – Blundell Dec 19 '15 at 19:46
  • Well I mean yes it doesn't fit in the screen but I ideally would want to be able to scroll up to see it if I scrolled up to the top of the layout – user1871869 Dec 19 '15 at 19:57
  • not sure off the top of my head, could try changing the `windowSoftInputMode` http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft – Blundell Dec 19 '15 at 22:12

0 Answers0