gpt4 book ai didi

android - 折叠工具栏内容稀松布不起作用

转载 作者:行者123 更新时间:2023-11-29 15:35:03 25 4
gpt4 key购买 nike

我在约束布局和Appbar布局中使用Coordinator布局以及CollapsingToolbarLayout,除了属性contentScrim之外,一切都工作正常。它没有按预期工作。当我向上滚动时,图像仍然显示在工具栏中,而不是显示我的 colorPrimary。

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".ProfileActivity">


<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/myCollapse"
app:title="Fizan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/mToolbar"
app:contentScrim="?android:attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:theme="@style/mToolbar"
app:layout_collapseMode="pin" />

<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/profile"
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">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="jdkhasjkdajksdhjkashdjkhsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsahsak"
android:textSize="35dp" />
</android.support.v4.widget.NestedScrollView>

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


</android.support.constraint.ConstraintLayout>

enter image description here

最佳答案

您需要做的就是将您的 <ImageView>高于您的 <Toolbar>就像下面这样:

  <android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/myCollapse"
app:title="Fizan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<ImageView ....../>

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />

关于android - 折叠工具栏内容稀松布不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52514051/

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