Kir Kir - 2 years ago 115
Android Question

How to use NestedScrollView

In my application I want use

NestedScrollView
into
DrawerLayout
.

And for this I write below code.

I want show FAB in bottom of layout, but show me below of card!

I don't want show in below of card, I want show bottom of layout!

Please see below image to understand what I mean:

enter image description here

My codes:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">

<android.support.v7.widget.CardView
android:id="@+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding8"
ads:cardBackgroundColor="@android:color/white"
ads:cardElevation="@dimen/size2"
app:contentPadding="@dimen/padding8">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="@dimen/size50">

<ImageView
android:id="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="@dimen/size35"
android:layout_height="@dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="@drawable/ic_comments"
android:tint="@color/darkBlueGrey" />

<TextView
android:id="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font16" />

<TextView
android:id="@+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font14" />

</RelativeLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="@dimen/padding5" />

</RelativeLayout>

</android.support.v7.widget.CardView>

</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="@+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">

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

</RelativeLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/padding15"
android:src="@drawable/ic_filter"
app:fabSize="normal" />

</RelativeLayout>

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

</android.support.v4.widget.DrawerLayout>


How can I fix this problem?

Answer Source

Hey man try this code :

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/toNightDrawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="end">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <RelativeLayout
                    android:id="@+id/reviewSerialFrag_newsCommentsLay"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="visible">

                    <android.support.v7.widget.CardView
                        android:id="@+id/reviewSerialFrag_newsCommentsCard"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/padding8"
                        ads:cardBackgroundColor="@android:color/white"
                        ads:cardElevation="@dimen/size2"
                        app:contentPadding="@dimen/padding8">

                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <RelativeLayout
                                android:id="@+id/reviewSerialFrag_newsCommentsHeaderLay"
                                android:layout_width="match_parent"
                                android:layout_height="@dimen/size50">

                                <ImageView
                                    android:id="@+id/reviewSerialFrag_newsCommentsHeaderImage"
                                    android:layout_width="@dimen/size35"
                                    android:layout_height="@dimen/size35"
                                    android:layout_centerVertical="true"
                                    android:alpha="0.8"
                                    android:src="@drawable/ic_comments"
                                    android:tint="@color/darkBlueGrey" />

                                <TextView
                                    android:id="@+id/reviewSerialFrag_newsCommentsUserTypeText"
                                    android:layout_width="wrap_content"
                                    android:layout_height="match_parent"
                                    android:layout_margin="@dimen/padding10"
                                    android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsHeaderImage"
                                    android:fontFamily="sans-serif-light"
                                    android:gravity="center_vertical"
                                    android:textColor="@color/darkBlueGrey"
                                    android:textSize="@dimen/font16" />

                                <TextView
                                    android:id="@+id/reviewSerialFrag_newsCommentsReviewTypeText"
                                    android:layout_width="wrap_content"
                                    android:layout_height="match_parent"
                                    android:layout_margin="@dimen/padding10"
                                    android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsUserTypeText"
                                    android:fontFamily="sans-serif-light"
                                    android:gravity="center_vertical"
                                    android:textColor="@color/darkBlueGrey"
                                    android:textSize="@dimen/font14" />

                            </RelativeLayout>

                            <android.support.v7.widget.RecyclerView
                                android:id="@+id/reviewSerialFrag_newsCommentsRecyclerView"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/reviewSerialFrag_newsCommentsHeaderLay"
                                android:layout_marginTop="@dimen/padding5" />

                        </RelativeLayout>

                    </android.support.v7.widget.CardView>

                </RelativeLayout>
                <!--EmptyList-->
                <RelativeLayout
                    android:id="@+id/reviewSerialFrag_EmptyLsy"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="gone">

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

                </RelativeLayout>

            </RelativeLayout>

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

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/reviewSerialFrag_FilterBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_margin="@dimen/padding15"
            android:src="@drawable/ic_filter"
            app:fabSize="normal" />

    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download