共享元素过渡动画问题

时间:2017-08-04 08:09:51

标签: android android-transitions

我有一个LoginActivity,其中包含两个按钮登录注册。我正在尝试分享从LoginActivityRegistrationActivity注册按钮。过渡动画正在发生,但动画并不顺利。问题是注册按钮在移至LoginActivity之前占据RegistrationActivity的整个高度和宽度。

以下是问题的屏幕截图。您可以看到注册按钮,其中包含布局的整个高度和宽度: enter image description here

我的LoginActivity代码,我跳转到ResgitrationActivity

Intent intent = new Intent(LoginActivity.this, RegistrationActivity.class);
                ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(LoginActivity.this, register, "register");
                startActivity(intent, options.toBundle());

在我onPause()LoginActivity的{​​{1}}中我称之为:

RegistrationActivity

这是我的@Override protected void onPause() { super.onPause(); overridePendingTransition(0, 0); }

style.xml

我的<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="android:colorPrimary">@color/colorPrimary</item> <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item> <item name="android:colorAccent">@color/colorAccent</item> <item name="android:windowContentTransitions">true</item> </style> <style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored"> <item name="android:colorAccent">#3b5998</item> <item name="android:textColor">#fff</item> </style> <style name="RegistrationButton" parent="Widget.AppCompat.Button.Colored"> <item name="android:colorAccent">#F44E3F</item> <item name="android:textColor">#FFF</item> </style> <style name="TextLabel" parent="ThemeOverlay.AppCompat.Light"> <!-- Hint color and label color in FALSE state --> <item name="android:textColorHint">#FFF</item> <!-- Label color in TRUE state and bar color FALSE and TRUE State --> <item name="android:colorAccent">#FFF</item> <item name="android:colorControlNormal">#FFF</item> <item name="android:colorControlActivated">#FFF</item> </style> </resources> 布局:

LoginActivity

这是我的<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:id="@+id/loginLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.ignite.a01hw909350.kolamdemo.LoginActivity"> <ImageView android:layout_width="200dp" android:layout_height="200dp" android:adjustViewBounds="true" android:alpha="0.5" android:scaleType="fitXY" android:src="@drawable/background_img" /> <ImageView android:layout_width="200dp" android:layout_height="200dp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:adjustViewBounds="true" android:alpha="0.5" android:rotation="180" android:scaleType="fitXY" android:src="@drawable/background_img" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_marginTop="16dp" android:orientation="vertical" android:padding="16dp"> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/TextLabel"> <android.support.v7.widget.AppCompatEditText android:id="@+id/loginEmail" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:drawableEnd="@drawable/ic_action_user" android:hint="@string/email" android:inputType="textEmailAddress" android:textAppearance="@style/TextAppearance.FontPath" android:textColor="@color/primary_text" android:textColorHint="@color/secondary_text" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/TextLabel"> <android.support.v7.widget.AppCompatEditText android:id="@+id/loginPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:drawableEnd="@drawable/ic_action_password" android:hint="@string/password" android:inputType="textPassword" android:textAppearance="@style/TextAppearance.FontPath" android:textColor="@color/primary_text" android:textColorHint="@color/secondary_text" /> </android.support.design.widget.TextInputLayout> <Button android:id="@+id/loginSubmit" style="@style/Widget.AppCompat.Button.Colored" android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/login" android:textAllCaps="false" android:textAppearance="@style/TextAppearance.FontPath" android:textColor="#fff" /> <Button android:id="@+id/registerText" style="@style/Widget.AppCompat.Button.Colored" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/register" android:textAllCaps="false" android:textAppearance="@style/TextAppearance.FontPath" android:textColor="#fff" android:theme="@style/RegistrationButton" /> </LinearLayout> </RelativeLayout> 布局:

RegistrationActivity

我正在使用Marshmallow驱动的Android设备进行测试。 为什么动画不流畅?

0 个答案:

没有答案