在这种情况下,我必须将工具栏保持在顶部,因此我已使用样式进行了设置,而不是添加CollapsingToolbarLayout
。我已应用顶部边距从工具栏移动顶部,否则地图被隐藏在工具栏后面。
由于此设置,向下滚动时出现黄色补丁(原色)。请看图片。
有什么办法可以消除这种颜色?或任何其他更好的方法来实现这一目标?
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="Fragments.Location">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Light"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/location_height"
android:layout_marginTop="?attr/actionBarSize"
android:fitsSystemWindows="true"
app:contentScrim="@android:color/transparent"
app:expandedTitleGravity="top"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false">
<!--
TODO:: You may use fragment to load map just below the ImageView.
The ImageView is a placeholder I used during the design as a reference.
-->
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@drawable/gmap_screenshot"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/location_nested_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:focusableInTouchMode="true">
<android.support.design.widget.TabLayout
android:id="@+id/location_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorLightGray"
android:elevation="@dimen/archive_card_elevation"
app:layout_constraintBottom_toTopOf="@+id/location_viewpager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"
app:tabSelectedTextColor="@color/colorWhite"
app:tabTextColor="@color/colorFieldHint"
tools:targetApi="lollipop">
<!--
TODO:: Remove the tab items ...
I have kept it for your reference however it is useless here..
as loading from Viewpager class..
-->
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Items" />
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/location_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/location_tab_layout" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>