【发布时间】:2020-01-14 17:57:30
【问题描述】:
我正在开发一个应用程序,我必须在其中显示内容列表。另外,我必须添加带有灵活空间的应用栏滚动。一切正常,但滚动行为不起作用。已经在互联网上搜索,但没有任何效果。
这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/sky_blue"
app:expandedTitleGravity="top"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="70dp"
app:layout_collapseMode="pin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginStart="50dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="50dp"
android:background="@drawable/rounded_edittext"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="20dp"
android:src="@drawable/ic_search" />
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:background="@null"
android:fontFamily="@font/opensans_regular"
android:hint="Search"
android:inputType="text"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="15sp" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"
tools:listitem="@layout/custom_movie_row"
android:layout_marginTop="200dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/></androidx.constraintlayout.widget.ConstraintLayout>
Recycler 视图工作正常,但它不会折叠 AppBar。
这是我想要在我的 Activity 中的行为
【问题讨论】:
标签: java android xml material-design