我希望在Android中实现与Google Map 相同的动画行为,其中 bottomsheet
滑动按钮固定在其顶部一段时间 . 达到一定高度后 bottomsheet
滑过按钮 . 我能够通过使用 layout_anchorGravity="top|left"
将按钮锚定到 bottomsheet
的顶部,但我不会让我疯狂 .
<androidx.coordinatorlayout.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical"
app:layout_anchor="@+id/bottomsheet"
app:layout_anchorGravity="top|left">
<Button
android:id="@+id/fab"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFFFFF"
android:textColor="#000000"
android:layout_marginBottom="10dp"/>
<Button
android:id="@+id/fab1"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFFFFF"
android:textColor="#000000"
/>
</LinearLayout>
<FrameLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
bottom sheet layout
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>