我希望gridview从tablayout(标记为红色)下方开始,但可以在透明工具栏和tablayout下方滚动。我尝试将marginTop设置为gridview,但gridview在该位置保持固定,并且不在工具栏和tablayout下滚动。有没有办法在gridview的第一行设置边距?
我的XML代码:
<android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Fragments.CompetitionFragment">
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:background="@color/statusBarColor"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="@+id/comptoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:background="@color/statusBarColor"
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/glostarslogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Competition"
android:textColor="@color/white"
android:textSize="20sp"
android:visibility="visible" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/MyTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabIndicatorColor="@color/white"
app:tabIndicatorHeight="3dp"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/fabs" />
</android.support.design.widget.CoordinatorLayout>