【发布时间】:2020-07-27 20:15:24
【问题描述】:
好的,情况就是这样……
在折叠工具栏布局中有一个线性布局。
这个 LinearLayout 包含一个我想要动画的 textview..
我试图找出一种方法来对其进行动画处理,以便它在向下滚动时从线性布局的顶部到底部进行动画处理。
你可能会在下面看到两个 Textviews.. 这是我给出相同效果错觉的方式。如果用户不感兴趣..
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawerLayout"
tools:context=".MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/toolbar4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="5dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|exitUntilCollapsed"/>
<LinearLayout
android:layout_marginTop="56dp"
android:layout_width="match_parent"
android:layout_height="156dp"
android:background="@color/colorAccent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="18dp"
android:textSize="20dp"
android:text=" Pick A Restaurant from the following "
android:textColor="#333"
android:layout_gravity="center_horizontal|bottom"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="18dp"
android:textSize="20dp"
android:text=" Pick A Restaurant from the following "
android:textColor="#333"
android:gravity="bottom"
android:layout_gravity="center_horizontal|bottom"
/>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:behavior_overlapTop="115dp"
app:layout_anchor="@id/toolbar4"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<!-- app:layout_behavior="@string/appbar_scrolling_view_behavior"-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/menu_drawer"
/>
</androidx.drawerlayout.widget.DrawerLayout>
好的,这里有一个小 gif 来演示我的问题
理想情况下,我希望文本视图在滚动时向下动画...
【问题讨论】:
标签: android xml android-layout android-coordinatorlayout