在android中的一个视图中布置注释和提要

时间:2017-08-01 06:34:49

标签: android android-recyclerview

我正在尝试在一个视图中创建评论和提要,并且它们都可以滚动。我可以在第一时间制作它,但是当我尝试向上和向下滚动时,它通常不像在recyclerView或scrollView中滚动那样平滑。这是我尝试的

<?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>

这是视图

View of comment and feeds

我可以将list_item_newsfeed布局放在recyclerView中,包括评论布局吗?所以我不必使用NestedScrollView。 谢谢

1 个答案:

答案 0 :(得分:0)

你有一个代表list_item_newsfeed的项目,对吗?

为什么不在RecyclerView中创建另一个单元格类型,例如标题单元格,您可以在其中显示新闻源项目?

标题单元格: Sample code by @Bronx