我使用了app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
但这里的工具栏是透明的。
使用上面的XML布局我片段因为我的要求是我需要在片段中使用不同的布局。任何帮助将不胜感激。
cordinatelayout中的ToolBar问题
Here is my code:
<?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"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop_BannerImage_Id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
android:src="@drawable/grass_background"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_event_home_Id"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/cast_expanded_controller_actionbar_bg_gradient_light"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/event_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center_horizontal"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/event_date_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/event_name_text_view"
android:layout_margin="10dp"
android:text="21-08-2016"
android:textSize="14sp" />
<TextView
android:id="@+id/event_attendee_count_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@+id/event_name_text_view"
android:layout_margin="10dp"
android:text="1000"
android:textSize="14sp" />
<!-- <Button
android:id="@+id/event_book_now_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/event_date_text_view"
android:layout_margin="15dp"
android:background="@color/primary"
android:text="Book Now"
android:textColor="@color/background_color" />-->
<View
android:id="@+id/event_info_view_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/event_attendee_count_text_view"
android:background="#cccccc" />
<LinearLayout
android:id="@+id/sub_linearLayout_1_day_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/event_info_view_line"
android:layout_margin="15dp"
android:orientation="horizontal">
<TextView
android:id="@+id/event_info_day_time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/event_info_day_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="21-08-2016" />
<!--<TextView
android:id="@+id/event_info_days_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2 days"
android:layout_marginStart="150dp"/>-->
</LinearLayout>
<LinearLayout
android:id="@+id/sub_linearLayout_2_place_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/sub_linearLayout_1_day_id"
android:layout_marginStart="15dp">
<TextView
android:id="@+id/event_info_location_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/event_info_location_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="21-08-2016" />
</LinearLayout>
<FrameLayout
android:id="@+id/map_event_info"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_below="@id/sub_linearLayout_2_place_id"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp"></FrameLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:elevation="10dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin"
android:layout_marginTop="@dimen/card_margin"
android:orientation="vertical">
<TextView
android:id="@+id/event_info_details_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Details"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/event_info_details_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingButtonEventInfoId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="160dp"
android:layout_gravity="bottom|end"
android:layout_marginRight="@dimen/fab_margin"
android:visibility="invisible"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingButtonEventInfoFeedBackId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="90dp"
android:layout_gravity="bottom|end"
android:layout_marginRight="@dimen/fab_margin"
android:visibility="invisible"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingButtonEventInfoShareId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:elevation="6dp"
app:backgroundTint="@color/colorAccent"
app:pressedTranslationZ="12dp"
android:layout_margin="@dimen/fab_margin" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
你的工具栏背景正在弄乱你的崩溃工具栏
android:background="@drawable/cast_expanded_controller_actionbar_bg_gradient_light"
尝试将其删除并运行。