共享元素转换不适用于第二个活动

时间:2018-05-07 13:36:36

标签: java android user-interface animation

您好我正在开发一个应用程序,我在textview上使用共享元素转换但是当我应用动画时没有任何事情发生,而且其他活动中的文本变得不可见,这是非常奇怪的我已经给这两个活动提供相同的转换名称仍然不如果有人可以帮助我,请了解问题所在。

这是登录活动

<?xml version="1.0" encoding="utf-8"?>
    <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:orientation="vertical"
        tools:context="com.ct.listrtrial.activities.LoginActivity"
    android:background="@color/colorPrimary">

        <com.ct.listrtrial.Custom.CustomTextViewMedium
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="30dp"
            android:text="Login"
            android:transitionName="@string/transition_name_signup"
            android:id="@+id/text_login"
            android:textColor="@color/White"
            android:textSize="35sp" />

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="25dp"
            android:id="@+id/login_card"
            app:cardBackgroundColor="@color/White"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <com.ct.listrtrial.Custom.CustomEditText
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:paddingLeft="10dp"
                    android:id="@+id/text_input_email"
                    >
                    <com.ct.listrtrial.Custom.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:drawableLeft="@drawable/message"
                        android:drawablePadding="10dp"
                        android:hint="Email id"
                        android:background="@android:color/transparent"/>
                </com.ct.listrtrial.Custom.CustomEditText>
                <View
                    android:id="@+id/card_divider"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/light_black"
                    />
                <com.ct.listrtrial.Custom.CustomEditText
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:paddingLeft="10dp"
                    android:id="@+id/text_input_password"
                    >
                    <com.ct.listrtrial.Custom.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:drawableLeft="@drawable/lock"
                        android:drawablePadding="10dp"
                        android:hint="Password"
                        android:background="@android:color/transparent"/>
                </com.ct.listrtrial.Custom.CustomEditText>
            </LinearLayout>
        </android.support.v7.widget.CardView>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <com.ct.listrtrial.Custom.CustomTextViewMedium
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="10dp"
                android:layout_marginTop="15dp"
                android:text="Forgot Password?"
                android:id="@+id/text_forgot_password"
                android:textColor="@color/White"
                android:textSize="18sp" />
        </RelativeLayout>

        <com.ct.listrtrial.widget.CustomButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@drawable/ripple_button_effect"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:text="Login"
            android:id="@+id/login_button"
            android:textSize="20sp" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.ct.listrtrial.Custom.CustomTextViewMedium
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="OR CONNECT WITH"
                android:textColor="@color/White"
                android:textSize="15sp" />
        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal"
            >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="20dp"
                android:layout_marginTop="10dp"
                android:layout_marginRight="50dp"
                >

                <com.ct.listrtrial.Custom.GoofleCustomImageView
                    android:id="@+id/facebook_image"
                    android:layout_width="wrap_content"
                    android:layout_height="45dp"
                    android:layout_centerInParent="true"
                    android:layout_marginRight="10dp"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"

                    android:src="@drawable/facebook"
                    />

                <com.ct.listrtrial.Custom.GoofleCustomImageView
                    android:id="@+id/google_image"
                    android:layout_width="wrap_content"
                    android:layout_height="45dp"
                    android:layout_marginLeft="10dp"
                    android:layout_toRightOf="@+id/facebook_image"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"

                    android:src="@drawable/google_plus_1" />
            </RelativeLayout>
        </LinearLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="250dp">

            <ImageView
                android:id="@+id/login_page_curve"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="gotoregister"

                android:src="@drawable/login_page_curve" />


            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="20dp"
                android:orientation="horizontal"
                >

                <com.ct.listrtrial.Custom.CustomTextViewMedium
                    android:id="@+id/or_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="130dp"
                    android:text="Or"
                    android:layout_marginTop="10dp"
                    android:textColor="@color/black"
                    android:textSize="17sp" />

                <com.ct.listrtrial.Custom.CustomTextViewBold
                    android:id="@+id/register_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_toRightOf="@+id/or_text"
                    android:text="Register"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="10dp"
                    android:textColor="@color/black"
                    android:textSize="17sp" />

            </RelativeLayout>
        </FrameLayout>
    </LinearLayout>

登录活动

public class LoginActivity extends AppCompatActivity {
        CustomEditText text_input_email,text_input_password;
        CustomButton login_button;
        GoofleCustomImageView google_image,facebook_image;
        ImageView login_page_curve;
        CustomTextViewMedium or_text,text_forgot_password,text_login;
        CustomTextViewBold register_text;
        View myView;
        boolean isUp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        initViews();


    }

    public void initViews(){
        text_input_email = (CustomEditText)findViewById(R.id.text_input_email);
        text_input_password = (CustomEditText)findViewById(R.id.text_input_password);
        login_button = (CustomButton)findViewById(R.id.login_button);
        google_image = (GoofleCustomImageView) findViewById(R.id.google_image);
        facebook_image = (GoofleCustomImageView) findViewById(R.id.facebook_image);
        login_page_curve  = (ImageView)findViewById(R.id.login_page_curve);
        or_text = (CustomTextViewMedium)findViewById(R.id.or_text);
        text_forgot_password = (CustomTextViewMedium)findViewById(R.id.text_forgot_password);
        register_text = (CustomTextViewBold)findViewById(R.id.register_text);
        text_login = (CustomTextViewMedium)findViewById(R.id.text_login);

    }

    public void gotoregister(View view) {
        Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation
                (LoginActivity.this,login_page_curve,
                        getResources().getString(R.string.transition_name_signup));

        startActivity(intent,options.toBundle());
        overridePendingTransition(R.anim.bottom_up,R.anim.bottom_down);
        finish();
    }
}

0 个答案:

没有答案