Moving a shared item between TextView and EditText

I tried to split the text between TextView

(source) and EditText

(destination), but it didn't work as expected.

The context of the problem is " Start action on shared item" using the attribute android:transtionName

.

After starting a new activity, all other common views ( ImageView

) have and display their values. EditText

knows the content because when I set focus it is displayed correctly. The logger " et.getText()

" shows what it EditText

matches, but is not displayed.

The sequence of operations is as follows:

  • Initial information "A" has initial data:

    • TextView

      value: "Hello world". android:transtionName="transition_text"

    • TextView

      display: "Hello world"
  • In a custom event, activity "B" is triggered by using a shared item transition and adding all items to be split.

  • In method 'B', onCreate

    shared data is received and set correctly. All elements contain their value, but the EditText does not display it:

    • EditText

      Meaning: "Hello world". android:transtionName="transition_text"

    • EditText

      display: ""

Is it possible that transition with an atomic element does not allow transitions between textual representations of different types ( TextView

EditText

)?

thank

+3


source to share


2 answers


Try getText from and then hidden and then setText to TextView

toString()

EditText



TextView tv = new TextView(this);
EditText et = new EditText(this);
tv.setText("Hello World");

String source = tv.getText().toString();
et.setText(source);

      

0


source


To solve this problem, I am moving my EditText and my TextView to layout and I am doing the animation on the layout.

This is for my edit text:

   <LinearLayout
        android:id="@+id/meeting_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:transitionName="tMeetingtitle">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
    </LinearLayout>

      

Then my TextView:



  <LinearLayout
    android:id="@+id/meeting_title"
    android:layout_width="wrap_content"
    android:layout_height="33dp"
    android:transitionName="tMeetingtitle"
    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
</LinearLayout>

      

In my snippet, I start animation:

            Intent intent = new Intent(mainActivity, DetailMeetingActivity.class);

            LinearLayout meetingTitle = (LinearLayout) view.findViewById(R.id.meeting_title);


            Pair<View, String> meetingTitlePair = Pair.create((View) meetingTitle, "tMeetingtitle");

            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mainActivity, meetingTitlePair);
            ActivityCompat.startActivity(mainActivity, intent, options.toBundle());

      

0


source







All Articles