How to fit the tab above of the screen when scrolling the page?

95 views Asked by At

enter image description here

I want to design the screen. layout, tab and grid view I want to scroll option. In scroll time, fix the tab on the header (Below of status bar) and grid view scroll to end of grid view content. In the bottom, I fixed bottom navigation bar.

This is my xml code:

<?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"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/layout_background"
 android:fillViewport="true"
 android:scrollbars="none">

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

    <RelativeLayout
        android:id="@+id/rlay_home_page_Tap"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/rlay_home_page_Tap1"
        android:background="@color/layout_background">

        <RelativeLayout
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="185dp"
            android:background="@drawable/main_header_selector"
            android:gravity="bottom|center">

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/llay_home_bottom2"
                android:layout_marginStart="12dp"
                android:layout_marginTop="12dp"
                android:layout_toEndOf="@+id/llay_home_bottom2" />

            <TextView
                android:id="@+id/textView10"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/profile_image"
                android:layout_marginTop="10dp"
                android:layout_toEndOf="@+id/img_fb_dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text=""
                android:textColor="#000"
                android:textSize="16dp" />


            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/profile_image"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="30dp"
                android:layout_marginTop="24dp"
                android:src="@drawable/ic_profile" />

            <TextView
                android:id="@+id/amsc_txt_home_fbusername"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView10"
                android:gravity="center"
                android:textColor="#fff"
                android:textSize="16dp" />

            <TextView
                android:id="@+id/amsc_txt_home_All_ImgCount"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView10"
                android:layout_marginBottom="60dp"
                android:layout_marginStart="20dp"
                android:gravity="center"
                android:text="125  \nPhotos"
                android:textColor="#fff"
                android:textSize="12dp" />

            <TextView
                android:id="@+id/amsc_txt_home_Fav_ImgCount"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView10"
                android:layout_alignParentEnd="true"
                android:layout_marginBottom="60dp"
                android:layout_marginEnd="20dp"
                android:gravity="center"
                android:text="125  \nFavouite"
                android:textColor="#fff"
                android:textSize="12dp" />

        </RelativeLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/simpleTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayout"
            android:gravity="center"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabSelectedTextColor="@color/tab_select_color"
            app:tabTextColor="@color/black_text_color" />

         <RelativeLayout
            android:id="@+id/llay_home_grd"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/simpleTabLayout"
            android:layout_above="@+id/linearLayout8"
            android:background="@color/layout_background"
            android:orientation="vertical">

            <GridView
                android:id="@+id/grid_test1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="2dp"
                android:layout_marginStart="2dp"
                android:background="@color/layout_background"
                android:horizontalSpacing="2dp"
                android:numColumns="3"
                android:verticalSpacing="2dp" />
            >
        </RelativeLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/linearLayout8"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:background="@android:color/white"
        android:orientation="horizontal">

        <LinearLayout
            android:id="@+id/linearLayout6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/white"
            android:orientation="horizontal">

            <android.support.design.widget.BottomNavigationView
                android:id="@+id/bottom_navigation_home1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:background="@color/wight"                    
               app:itemIconTint="@drawable/bottom_navigation_color_selector"
              app:itemTextColor="@drawable/bottom_navigation_color_selector"
                app:menu="@menu/my_navigation_home" />

        </LinearLayout>
        <LinearLayout
            android:id="@+id/linearLayout7"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/white"
            android:orientation="horizontal"
            android:visibility="gone">
            <android.support.design.widget.BottomNavigationView
                android:id="@+id/bottom_navigation_home2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:background="@color/wight"                    
              app:itemIconTint="@drawable/bottom_navigation_color_selector2"
             app:itemTextColor="@drawable/bottom_navigation_color_selector2"
                app:menu="@menu/my_navigation_home2" />
        </LinearLayout>
    </RelativeLayout>
    <ImageView
        android:id="@+id/img_take_cam_but"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="20dp"
        android:onClick=""
        android:background="@drawable/ic_capture"/>
   </RelativeLayout>
   </FrameLayout>

Above code , gridview only scrolling.How to scroll image type.

1

There are 1 answers

3
Kousei On

use appbarlayout and drawer layout for doing the tab part

<android.support.design.widget.CoordinatorLayout>
    <android.support.design.widget.AppBarLayout>
        <android.support.v7.widget.Toolbar/>
        <android.support.design.widget.TabLayout/>
    </android.support.design.widget.AppBarLayout>
    <!---your--layout--here---> 
</android.support.design.widget.CoordinatorLayout>