Android ImageПросмотреть, как перейти на другой макет - PullRequest
0 голосов
/ 21 октября 2018

Я видел много библиотек, таких как TransitionManager, но не могу делать то, что хочу.

Я хочу переместить ImageView, как показано ниже анимации https://codepen.io/elmahdim/pen/tEeDn

, как только я нажму imageView, я хочу переместить это изображение в кнопку с идентификатором «Корзина»

Мой макетxml как показано ниже

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="10"
    android:id="@+id/mainView"
    android:orientation="vertical"
    tools:context=".MainActivity">

     <ScrollView
        android:layout_weight="8"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="0dp">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:weightSum="5"
            android:layout_height="match_parent">
            <LinearLayout
                android:id="@+id/first"
                android:background="@color/colorPrimaryDark"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_gravity="center_horizontal|center_vertical"
                android:gravity="center_vertical|center_horizontal"
                android:orientation="vertical"
                android:layout_height="wrap_content">
                <ImageView
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:src="@drawable/americano"
                    />
                <TextView
                    android:textSize="25dp"
                    android:textAlignment="center"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="1번째"
                    />
            </LinearLayout>
                        ..... 

                        .....
      </ScrollView>


<LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="2"
        android:layout_height="0dp">
        <Button
            android:layout_width="wrap_content"
            android:text="Cart"
            android:id="@+id/Cart"
            android:layout_height="wrap_content" />
       .... 
       ....
 </LinearLayout>

В Activity я пытался использовать пример кода библиотеки TransitionManager, но он не дал мне эффекта.То, что я хочу сделать, это переместить imageView в Button id "Корзина"

first= (LinearLayout)findViewById(R.id.first);
        first.setOnClickListener(new View.OnClickListener() {
            boolean mToRightAnimation;
            @Override
            public void onClick(View v) {
                TransitionManager.beginDelayedTransition(transitionsContainer,
                        new ChangeBounds().setPathMotion(new ArcMotion()).setDuration(500));

                LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) first.getLayoutParams();
                params.gravity =Gravity.RIGHT | Gravity.BOTTOM;

                first.setLayoutParams(params);
            }
        });

1 Ответ

0 голосов
/ 21 октября 2018

Вы можете попробовать https://github.com/matrixdevz/FlyToCartAnimation

Более подробную информацию вы можете найти здесь http://codezlab.com/add-to-cart-fly-animation/

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...