如何为底片制作动画[关闭]

问题描述 投票:-1回答:1
在素材页面上,当扩展和更改StatusBar的颜色时,我遇到了一个底部动画,带有工具栏的外观;有谁知道如何重复这种效果。老师/例子/想法?https://storage.googleapis.com/spec-host-backup/mio-components%2Fassets%2F1mYYvVz_dCIx0bRyY_VV4hOs9709f1ESb%2Fmodal-behavior-dismissal-close.mp4
android material-design android-animation bottom-sheet
1个回答
0
投票
您想在哪个视图中显示此底页,使CoordinatorLayout成为根视图。 CoordinatorLayout是必需的。

您的片段或活动视图

<androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/bottom_sheet_log_out" /> </androidx.coordinatorlayout.widget.CoordinatorLayout>

底页

<com.google.android.material.card.MaterialCardView 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:id="@+id/bottomSheetLogOutCard" android:layout_width="match_parent" android:layout_height="wrap_content" app:behavior_hideable="true" app:behavior_peekHeight="0dp" app:cardCornerRadius="8dp" app:cardElevation="@dimen/bottom_sheet_elevation" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" tools:layout_gravity="bottom"> </com.google.android.material.card.MaterialCardView>
此行很重要。app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"

MaterialCardView是可选的,您可以使用任何想要的。

代码

private lateinit var bottomSheetLogOutBehavior: BottomSheetBehavior<CardView> ... // init your bottomsheet bottomSheetLogOutBehavior = BottomSheetBehavior.from(bottomSheetLogOutCard) // To Expand bottomSheetLogOutBehavior.state = BottomSheetBehavior.STATE_EXPANDED // To hide bottomSheetLogOutBehavior.state = BottomSheetBehavior.STATE_HIDDEN
© www.soinside.com 2019 - 2024. All rights reserved.