0

I want is the following sort of layout:

<CoordinatorLayout>
  <ToolBar></ToolBar>
  <RelativeLayout></RelativeLayout>
  <RecyclerView></RecyclerView>
  <LinearLayout>
    <EditText></EditText>
  </LinearLayout>
<CoordinatorLayout>

However, my issue is when I click on my EditText, the keyboard pops up and shows the RecyclerView perfectly, but when I try to scroll further up, I can't seem to see my RelativeLayout, nor can I see my ToolBar. However, when I don't have the keyboard up, I can see everything fine. Here are some images showing what's happening: This is my image before I click on the keyboard

This is my image after I click the keyboard

I understand it is most likely because I don't have a parent ScrollView that nests the entire layout, but I can't seem to have that because of my RecyclerView. Is there either a. a way to implement a sort of custom RecyclerView so I can have a ScrollView parent layout or b. find some way for me to be able to scroll and see my ToolBar and RelativeLayout in addition to my RecyclerView? I've included my attempt with a ScrollView but I still can only see the RecyclerView when I click on the EditText. Any help is appreciated. Thanks!

Code: AndroidManifest.xml:

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

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>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/layout_comments">
            <RelativeLayout
                android:layout_marginTop="?attr/actionBarSize"
                android:id="@+id/view_post"
                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>


            <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_below="@id/view_post"
                android:layout_above="@id/send_message"
                android:id="@+id/view_comments">
            </android.support.v7.widget.RecyclerView>
        </RelativeLayout>
    </ScrollView>


</android.support.design.widget.CoordinatorLayout>
user1871869
  • 3,317
  • 13
  • 56
  • 106
  • use only `stateAlwaysHidden|adjustPan` – IntelliJ Amiya Dec 15 '15 at 09:21
  • @IntelliJAmiya I did as you suggested and it did not fix my problem. Do you have any other suggestions? – user1871869 Dec 15 '15 at 16:48
  • Try this http://stackoverflow.com/questions/3295672/android-soft-keyboard-covers-edittext-field – piotrek1543 Dec 15 '15 at 18:05
  • the same solution: http://stackoverflow.com/questions/4207880/android-how-do-i-prevent-the-soft-keyboard-from-pushing-my-view-up – piotrek1543 Dec 15 '15 at 18:05
  • Those actually do not answer my question. 2nd question answers how you can hide a view which is using adjustNothing and 1st question asks why the EditText is not showing. My question is why my View is being pushed up and not being shown when I click on the EditText. – user1871869 Dec 16 '15 at 06:16

2 Answers2

0

According to:

I understand it is most likely because I don't have a parent ScrollView that nests the entire layout, but I can't seem to have that because of my RecyclerView. Is there either a. a way to implement a sort of custom RecyclerView so I can have a ScrollView parent layout or b. find some way for me to be able to scroll and see my ToolBar and RelativeLayout in addition to my RecyclerView? I've included my attempt with a ScrollView but I still can only see the RecyclerView when I click on the EditText. Any help is appreciated. Thanks!

So you need to extend range of existing ScrollView view. Just put AppBarLayout and RelativeLayout view into new vertical oriented 'LinearLayout', as ScrollView takes only one view. This new created ViewGroup would be an only child of 'CoordinatorLayout'.

Once you wrap AppBarLayout and RelativeLayout' into new madeLinearLayout, put it into existingScrollView`.

Hope you now understand how to do it. If not, tell me and I would tomorrow in the early morning edit my post and change your actual code with desired one.

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • Well my issue is that the `ScrollView` can not be a parent of a `RecyclerView` because then you would have a nested scroll view wouldn't you? – user1871869 Dec 17 '15 at 08:42
  • no, because `ScrollView` can only has only one child. The child of ScrollView would be nested ViewGroups holder. – piotrek1543 Dec 17 '15 at 08:45
0

put your <RecyclerView> in the one <LinearLayout> and set your linearlayout as match_parent but in your RecyclerView set height="0dp" and use weight="1" like this :

    <CoordinatorLayout>
         <ToolBar></ToolBar>
         <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent">

                   <RecyclerView
                       android:layout_width="match_parent"
                       android:layout_height="0dp"
                       android:layout_weight="1"></RecyclerView>

        </LinearLayout>
        <EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              app:layout_anchorGravity="bottom"></EditText>
    <CoordinatorLayout>

and then, when your keyboard opens your recyclerview will not be under keyboard and your can scroll to see items under keybard

good lock