问题描述
我有一个列表,可以使用/www/etc/
刷掉。我想实现一种类似于Gmail android应用程序中的动画,在该动画中,当您将电子邮件刷掉时,就会露出彩色背景。因此,我试图在移动的视图下的MotionLayout
中放置一个ImageView
,以便当该视图消失时它将在下面显示MotionLayout
。
这是元素的布局:
ImageView
即使在“设计”编辑器中,图像似乎也在那里,并且如果我播放<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/reading_list_item_motion"
android:layout_width="match_parent"
android:layout_height="72dp"
app:layoutDescription="@xml/reading_list_item_scene">
<!-- The image under the element that moves -->
<ImageView
android:id="@+id/reading_list_item_back"
android:layout_width="match_parent"
android:layout_height="72dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/reading_list_item_layout"
android:layout_width="match_parent"
android:layout_height="72dp"
android:gravity="center"
android:paddingLeft="@dimen/search_result_padding"
android:paddingRight="@dimen/search_result_padding"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/reading_list_item_icon"
android:layout_width="@dimen/ic_search_result"
android:layout_height="@dimen/ic_search_result"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:contentDescription="Search result icon"
app:error="@{@drawable/ic_default_search_result}"
app:imageUrl="@{book.best_book.small_image_url}"
app:layout_constraintEnd_toStartOf="@id/reading_list_item_info_layout"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_default_search_result" />
<LinearLayout
android:id="@+id/reading_list_item_info_layout"
android:layout_width="316dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toEndOf="@+id/reading_list_item_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6">
<TextView
android:id="@+id/reading_list_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:singleLine="false"
android:text="@{book.best_book.title}"
android:textColor="@color/textSecondary"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/reading_list_item_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text='@{"by " + book.best_book.author.name }'
android:textColor="@color/textSecondary" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.motion.widget.MotionLayout>
,一切都会按预期进行,但是在启动应用程序时,MotionLayout
还是看不见。
我想到的另一种方法是在移动视图的末尾附加ImageView
,以便在它离开屏幕时,ImageView
进入视图。我不确定如何实现此目的,因为ImageView
应该和屏幕一样宽,而ImageView
显然不起作用
有人知道如何实现此动画吗?
谢谢!
编辑:这是我想要它的外观的图像。屏幕上显示的项目越多,显示的红色背景越多。
这是MotionScene xml:
match_parent
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)