我的应用程序看起来有点像这样(https://dribbble.com/shots/2189587-Add-to-cart)
我想类似地将产品的快照移动到下面的购物车中。我以前从未使用过动画,所以我有点难以理解这一点。
对于您的答案,假设产品图片在 ImageView 中,而购物车按钮是右下角的浮动操作按钮。
我的页面代码在这里:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="product" type="com.example.irtazasafi.ilovezappos.Result"/>
</data>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="@color/cardview_light_background"
android:gravity="center">
<ImageView
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@color/cardview_light_background"
android:src="@mipmap/zappos"
android:textAlignment="center"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@{product.getProductId()}"
android:textAlignment="center" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{product.getPercentOff()}"
android:textSize="20sp"
android:layout_marginRight="250dp"
android:textColor="@color/colorAccent"
android:id="@+id/discountAmount"/>
</android.support.design.widget.CoordinatorLayout>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="10dp"
android:id="@+id/productImage"
android:scaleType="centerCrop"
android:backgroundTint="@color/cardview_light_background"
android:background="@color/cardview_light_background" />
<TextView
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="43dp"
android:background="?android:attr/colorPrimary"
android:text="@{product.getBrandName()}"
android:textColor="@android:color/black"
android:textSize="35sp"
android:textAlignment="center"/>
<TextView
android:layout_marginTop="0dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary"
android:text="@{product.getProductName()}"
android:textColor="@android:color/black"
android:textSize="15sp"
android:textAlignment="center"/>
<TextView …Run Code Online (Sandbox Code Playgroud)