5

I am trying to do an Android Shared Transtion between a TextView and a EditText´ but when showing the resulting Activity the text in theEditViewhave been shifted up. See attached pictures. Also, clicking on theEditView` after the transition will restore the text to the correct position.

First clicking any row in RecylcerView:

enter image description here

The cell view, the date TextEdit and the Name TextEdit are shared to the next activity. The cell background is transitioned into the toolbar.

enter image description here

Start activity cell layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/adapter_actionlist"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:clickable="true"
              android:focusable="true"
              android:background="?android:attr/selectableItemBackground"
              android:transitionName="@string/transition_key_action" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="72dp"
        >

        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/adapter_actionList_checkBox"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="12dp"/>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_centerVertical="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="72dp"
            android:layout_marginRight="16dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLines="2"
                android:ellipsize="end"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Large Text"
                android:id="@+id/adapter_actionlist_toplabel"
                android:paddingTop="0dp"
                android:paddingBottom="0dp"
                android:textSize="14sp"
                android:transitionName="@string/transition_key_action_name"
                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Medium Text"
                android:id="@+id/adapter_actionlist_bottomlabel"
                android:paddingTop="0dp"
                android:paddingBottom="0dp"
                android:autoText="false"
                android:textSize="14sp"
                android:transitionName="@string/transition_key_action_date"
                />
        </LinearLayout>

    </RelativeLayout>
</LinearLayout>

End layout for activity:

<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">

    <android.support.v7.widget.Toolbar
        android:id="@+id/activity_action_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primary_color"
        app:contentInsetEnd="0dp"
        app:contentInsetStart="0dp"
        android:elevation="4dp"
        android:fitsSystemWindows="true"
        app:navigationIcon="@drawable/abc_ic_ab_back_mtrl_am_alpha"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:transitionName="@string/transition_key_action">

            <LinearLayout
                android:id="@+id/actvity_action_focus_placeholder"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_marginTop="56dp"
                android:layout_marginLeft="16dp"
                android:descendantFocusability="beforeDescendants"
                android:focusableInTouchMode="true"
                android:paddingBottom="6dp">

                <EditText
                    android:id="@+id/activity_action_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Title"
                    android:layout_marginRight="16dp"
                    android:imeOptions="actionDone"
                    android:singleLine="true"
                    android:ellipsize="none"
                    android:inputType="text"
                    android:textSize="22sp"
                    android:textColor="#fff"
                    android:focusable="true"
                    android:background="@android:color/transparent"
                    android:transitionName="@string/transition_key_action_name"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:text="Från: [Möte] (Datum)"
                    android:id="@+id/activity_action_meetingdate"
                    android:textColor="#fff"
                    android:layout_marginBottom="6dp"
                    android:layout_marginRight="16dp"
                    android:transitionName="@string/transition_key_action_date"/>

            </LinearLayout>

    </android.support.v7.widget.Toolbar>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_action_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".Activities.ActionActivity">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/activity_action_recyclerview"
                android:scrollbars="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="beforeDescendants"/>

    </android.support.v4.widget.SwipeRefreshLayout>

</LinearLayout>

Transition code:

private void startActionActivity(int selectedRow, View animateFromView)
{
    Intent intent = new Intent(this, ActionActivity.class);
    Action selectedAction = mAdapter.getActionAtPosition(selectedRow);
    intent.putExtra(Constants.SELECTED_ACTION_ID_KEY, selectedAction.id);

    if (animateFromView != null) {

        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
                Pair.create(animateFromView, getResources().getString(R.string.transition_key_action)),
                Pair.create(animateFromView.findViewById(R.id.adapter_actionlist_toplabel), getResources().getString(R.string.transition_key_action_name)),
                Pair.create(animateFromView.findViewById(R.id.adapter_actionlist_bottomlabel), getResources().getString(R.string.transition_key_action_date)));

        startActivity(intent, options.toBundle());
    }
    else {
        startActivity(intent);
    }
}
Sunkas
  • 9,542
  • 6
  • 62
  • 102
  • Hi Sunkas. I was searching for this bug cause I'm facing the same weird issue, this bug is bad. I've tried so many things without any success. have u found out why it's happening? have u found a solution fo this? It's just ugly. it's like the Textview doesn't respect the view bounds at all. would appretiate if we could talk about it a bit – Shahin Nov 26 '19 at 20:28
  • oh, and I just saw that you posted your question in 2015! it's awfully late to bring up this bad memory of yours. but there isn't a single article on the internet about this. it's starting to become a nightmare for me – Shahin Nov 26 '19 at 20:31
  • Sorry, it's a long gone app of a customer of mine. Do not remember if and how I solved it. – Sunkas Nov 27 '19 at 13:25
  • 1
    You're way ahead of me then in terms of being a developer. I've just started dealing with this. Thanks anyways – Shahin Nov 27 '19 at 23:53

0 Answers0