gpt4 book ai didi

android - CoordinatorLayout 推送的 Actionbar

转载 作者:太空宇宙 更新时间:2023-11-03 13:44:32 24 4
gpt4 key购买 nike

操作栏被 CoordinatorLayout 推送,如下图所示:

(ActionBar 看起来缺少它的上半部分,如果我返回到另一个 Activity ,它仍然缺少上半部分)

enter image description here

  • 我错过了什么?
  • 我可以在 ViewPager 中使用 CoordinatorLayout 还是不应该在其中使用它?
  • CoordinatorLayout可以在fragment中使用吗

    test.xml:

      <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="256dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/CollapsingToolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:collapsedTitleGravity="center"
    app:collapsedTitleTextAppearance="@style/TextAppearance.Design.CollapsingToolbar.Expanded.Shadow"
    app:contentScrim="?attr/colorPrimary"
    app:expandedTitleMarginEnd="50dp"
    app:expandedTitleMarginStart="50dp"
    app:expandedTitleTextAppearance="@style/TextAppearance.Design.CollapsingToolbar.Expanded.Shadow"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
    android:id="@+id/IV"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:scaleType="centerInside"
    app:layout_collapseMode="parallax"
    app:layout_scrollFlags="scroll|enterAlways" />

    <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:layout_collapseMode="pin"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </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"
    android:background="@color/whiteBackground"
    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="10dp"
    app:cardBackgroundColor="@color/grayBackground"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp">

    <TextView
    android:id="@+id/tv1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="@dimen/activity_horizontal_margin"
    android:textColor="@color/colorPrimary"
    android:textStyle="bold" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    app:cardBackgroundColor="@color/grayBackground"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp">

    <TextView
    android:id="@+id/tv2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:lineSpacingExtra="8dp"
    android:padding="@dimen/activity_horizontal_margin"
    android:textSize="20sp" />
    </android.support.v7.widget.CardView>
    </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/FAB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    android:clickable="true"
    app:backgroundTint="@color/colorPrimaryDark"
    app:layout_anchor="@id/appbar"
    app:layout_anchorGravity="bottom|left|start"
    app:rippleColor="@android:color/darker_gray"
    app:srcCompat="@drawable/ic_more_black_24dp" />

    </android.support.design.widget.CoordinatorLayout>

最佳答案

我通过从 CoordinatorLayout 中删除 android:fitsSystemWindows="true" 解决了这个问题。

关于android - CoordinatorLayout 推送的 Actionbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45400747/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com