0

i'm trying to create comment and feeds in one view and both of it is scrollable. I can make it at first time, but when i try to scroll up and down, it doesn't smooth like usually scroll in recyclerView or scrollView. This is what i try

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include layout="@layout/dc_toolbar"/>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroller"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="1dp"
            android:orientation="vertical"
            android:descendantFocusability="blocksDescendants">

            <include layout="@layout/list_item_newsfeed"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/dc_dark_grey" />

    <RelativeLayout
        android:id="@+id/rl_comment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/dc_white">

        <ImageView
            android:id="@+id/iv_add_location"
            android:layout_width="35dp"
            android:layout_height="50dp"
            android:layout_alignBottom="@id/et_write_comment"
            android:layout_alignParentStart="true"
            android:background="@drawable/btn_click_bg_grey"
            android:paddingBottom="11dp"
            android:paddingEnd="4dp"
            android:paddingStart="4dp"
            android:paddingTop="11dp"
            android:src="@drawable/ic_room" />

        <ImageView
            android:id="@+id/iv_add_photo"
            android:layout_width="35dp"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/iv_add_location"
            android:layout_alignTop="@id/iv_add_location"
            android:layout_toEndOf="@id/iv_add_location"
            android:background="@drawable/btn_click_bg_grey"
            android:paddingBottom="10dp"
            android:paddingEnd="4dp"
            android:paddingStart="4dp"
            android:paddingTop="10dp"
            android:src="@drawable/ic_camera_send" />

        <Button
            android:id="@+id/btn_send"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentEnd="true"
            android:background="@drawable/ic_send_type" />

        <EditText
            android:id="@+id/et_write_comment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/btn_send"
            android:layout_toEndOf="@id/iv_add_photo"
            android:layout_toStartOf="@id/btn_send"
            android:background="@drawable/bg_outline_white"
            android:ems="10"
            android:hint="Tulis komentar disini.."
            android:padding="8dp" />
    </RelativeLayout>
</LinearLayout>

and this is the view

View of comment and feeds

can i put list_item_newsfeed layout inside recyclerView too including comment layout? So i don't have to use NestedScrollView. Thank you

MNFS
  • 305
  • 4
  • 17

1 Answers1

0

You have a single item representing the list_item_newsfeed, right?

Why don't you just create another cell type, for example header cell, in the RecyclerView where you can show your newsfeed item?

Header cell: Sample code by @Bronx

Seishin
  • 1,493
  • 1
  • 19
  • 30