-2

I have used ViewPager with NestedScrollView and RecyclerView. All is working fine expect while loading the screen the recycler view loads first and then view pager with jerk(not smoothly) and its not look good.

Right now I am implementing with design side not set any adapter for view pager. I have not populated data not for view pager nor for recyclerview.

Xml:

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

<hammerapps.views.CustomNestedScrollView
    android:id="@+id/scroll_main"
    android:layout_width="match_parent"
    android:layout_gravity="fill_vertical"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:orientation="vertical">

            <android.support.v4.view.ViewPager
                android:id="@+id/pager_banner"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/gray_bg"
                 />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="24dp"
            android:orientation="horizontal"
            android:visibility="visible">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <hammerapps.views.TextViewKarlaRegular
                    android:id="@+id/txt_cat_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:layout_marginTop="4dp"
                    android:text="EXPLORE"
                    android:textColor="@color/blue_color"
                    android:textSize="14dp" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recycler_home_explore"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:orientation="vertical"
            android:visibility="visible">

            <hammerapps.views.TextViewKarlaBold
                android:id="@+id/txt_cat1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:layout_marginLeft="16dp"
                android:text="EXCLUSIVE"
                android:textColor="@color/blue_color"
                android:textSize="14dp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/border_yellow"
                android:orientation="vertical"
                android:layout_marginTop="16dp"
                android:visibility="visible">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="16dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginBottom="16dp"
                    android:orientation="vertical">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/recycler_home_exclusive"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:visibility="visible" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="30dp"
            android:layout_marginBottom="16dp"
            android:orientation="vertical">

            <hammerapps.views.TextViewKarlaBold
                android:id="@+id/txt_get_social"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:text="GET SOCIAL"
                android:textColor="@color/blue_color"
                android:textSize="14dp" />

            <hammerapps.views.TextViewKarlaBold
                android:id="@+id/txt_twicestyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:layout_marginTop="8dp"
                android:text="\@twicelifestyle \#twicelifestyle"
                android:textColor="@color/orange"
                android:textSize="12dp" />

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

        </LinearLayout>

        <LinearLayout
            android:id="@+id/lin_footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:gravity="bottom"
            android:orientation="horizontal"
            android:weightSum="10">

            <hammerapps.views.TextViewKarlaRegular
                android:id="@+id/txt_view_gallery"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="4"
                android:background="@color/blue_light_bg_color"
                android:gravity="center"
                android:padding="16dp"
                android:text="VIEW GALLERY"
                android:textColor="@color/white"
                android:textSize="12dp"
                />

            <hammerapps.views.TextViewKarlaRegular
                android:id="@+id/txt_upload_pic"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="6"
                android:background="@color/red"
                android:gravity="center"
                android:padding="16dp"
                android:text="UPLOAD YOUR PICTURE"
                android:textColor="@color/white"
                android:textSize="12dp" />
        </LinearLayout>
    </LinearLayout>
</hammerapps.views.CustomNestedScrollView>

</FrameLayout>

Issue :

enter image description here

Piyush
  • 18,895
  • 5
  • 32
  • 63

1 Answers1

4

Finally I got the answer with myself !!

I have implemented custom NestedScrollView and override this two methods and its working like a charm !

@Override
public void requestChildFocus(View child, View focused) {
    Log.d(getClass().getSimpleName(), "Request focus");

}

@Override
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
    Log.d(getClass().getSimpleName(), "Request focus descendants");
    //return super.onRequestFocusInDescendants(direction, previouslyFocusedRect);
    return false;
}
Piyush
  • 18,895
  • 5
  • 32
  • 63