需要帮助创建一个看起来像谷歌地图中的探索按钮的布局
通过点击屏幕底部的按钮,面板从底部到屏幕中间出现(包括动画)
然后需要提供向上或向下滑动面板的能力
我几乎通过MotionLayout (alpha-2) 完成了它,另一个解决方案也不错
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetStart="@+id/start"
app:constraintSetEnd="@+id/end"
app:duration="1000"
app:interpolator="linear" />
<OnSwipe
app:touchAnchorId="@+id/container"
app:touchAnchorSide="top"
app:dragDirection="dragUp" />
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<CustomAttribute
app:attributeName="BackgroundColor"
app:customColorValue="#FF00FF" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/container"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<CustomAttribute
app:attributeName="BackgroundColor"
app:customColorValue="#00FFFF" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/half">
<Constraint
android:id="@id/container"
android:layout_width="0dp"
android:layout_height="300dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<CustomAttribute
app:attributeName="BackgroundColor"
app:customColorValue="#00FFFF" />
</Constraint>
</ConstraintSet>
</MotionScene>
然后我设置进度(但没有动画)
private fun onBottomButtonClick() {
//motionLayout.transitionToState(R.id.half) //:(
//motionLayout.setTransition(R.id.start, R.id.end) //locks layout
motionLayout.progress = 0.5f
}
谢谢