Lak*_*tta 5 xml android android-studio android-constraintlayout android-motionlayout
我有一个场景,它有一个开始约束布局和一个结束。问题是,滑动动画很突然。它只是在单个帧中将开始到结束以及结束到开始进行转换,并且不进行动画处理。Onclick 手势确实有动画效果,但我想使用滑动手势
xml 文件夹内的motionscene.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@layout/backdrop_layout_end"
motion:constraintSetEnd="@layout/backdrop_layout_start"
motion:motionInterpolator="easeInOut"
motion:transitionDisable="false"
motion:duration="200">
<OnSwipe
motion:touchAnchorId="@id/toggle"
motion:dragDirection="dragDown"
motion:maxAcceleration=".5"
/>
</Transition>
</MotionScene>
Run Code Online (Sandbox Code Playgroud)
布局文件夹内的layout_start.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:motion="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/backdrop_back"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/amber_800"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/backdrop_front"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1"
android:background="@drawable/upper_rounded_corners"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="100dp">
<ImageView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/margin_10"
android:id="@+id/toggle"
android:layout_gravity="center"
android:src="@drawable/ic_adjust"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
布局文件夹中的layout_end.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:motion="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/backdrop_back"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/amber_800"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="match_parent"
android:id="@+id/backdrop_front"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="1"
android:layout_marginTop="@dimen/margin_10"
android:background="@drawable/upper_rounded_corners"
android:orientation="vertical"
android:layout_width="match_parent">
<ImageView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/margin_10"
android:id="@+id/toggle"
android:layout_gravity="center"
android:src="@drawable/ic_adjust"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
另外,我在运动场景的“end”参数中使用layout_start,在“start”参数中使用layout_end。这不是一个错字。如果我采取相反的方式,则向下滑动寄存器向上切换,向上滑动寄存器向下切换。我几乎相信这个库有一个错误。任何帮助表示赞赏。谢谢 !
| 归档时间: |
|
| 查看次数: |
601 次 |
| 最近记录: |