滚动页面时如何适应屏幕上方的选项卡?

时间:2017-09-05 09:11:35

标签: android xml android-gridview xml-layout

enter image description here

我想设计屏幕。布局,选项卡和网格视图我想滚动选项。在滚动时,修复标题上的选项卡(状态栏下方)和网格视图滚动到网格视图内容的结尾。在底部,我修复了底部导航栏。

这是我的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"
 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>

上面的代码,gridview只滚动。如何滚动图像类型。

1 个答案:

答案 0 :(得分:0)

使用appbarlayout和抽屉布局来执行标签部分

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