Transition blinks after changing orientation

UPDATE

Ive discovered an error with Google https://issuetracker.google.com/issues/63663775

I am trying to use makeSceneTransitionAnimation in my current android application.

I have a Source Activity that contains a Fragment , and inside the Fragment there is a RecyclerView .

When I click on an image in RecyclerView I go to my Target Activity , which contains a fragment that correctly displays the image with acceptable animation.

Pressing the back button correctly changes the animation.

The above works great in both portrait and landscape orientations.

A problem with BLINKING occurs when I change the orientation when viewing the target fragment, and then click the "Back" button.

There are other problems, such as the image not returning directly to its original position, and on older devices I see horizontal lines, such as interference from a poorly tuned analog television.

Using it BLINKING is very bad, the screen of the device completely BLACK takes about 500 ms.

I downloaded and deployed the transition application for common google elements and added that it has the same β€œFeature”.

I tried several solutions and none of them worked, like this .

Below is the page where there is a problem.

LOGCAT ADDED

 07-21 12:57:18.097 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=30KB, data=21KB 07-21 12:57:18.099 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=30KB, data=23KB 07-21 12:57:18.099 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 128KB 07-21 12:57:20.540 1962-2058/com.incentive.yellowpages D/OkHttp: --> GET http://www.spyur.am/en/home/search-1/?company_name=Happy http/1.1 07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=61KB, data=55KB 07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=61KB, data=55KB 07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 256KB 07-21 12:57:21.084 1962-2058/com.incentive.yellowpages D/OkHttp: <-- 200 OK http://www.spyur.am/en/home/search-1/?company_name=Happy (543ms, unknown-length body) 07-21 12:57:22.197 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=124KB, data=93KB 07-21 12:57:22.197 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=98KB, data=59KB 07-21 12:57:22.377 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=101KB, data=79KB 07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=101KB, data=79KB 07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 512KB 07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 4MB to compile boolean org.jsoup.parser.HtmlTreeBuilderState$7.process(org.jsoup.parser.Token, org.jsoup.parser.HtmlTreeBuilder) 07-21 12:57:22.701 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 4MB to compile void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int) 07-21 12:57:24.495 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=245KB, data=178KB 07-21 12:57:24.495 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=216KB, data=130KB 07-21 12:57:25.040 1962-2058/com.incentive.yellowpages D/OkHttp: --> GET http://www.spyur.am/en/companies/happy-print-printing-house/34896 http/1.1 07-21 12:57:25.101 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=true 07-21 12:57:25.437 1962-2058/com.incentive.yellowpages D/OkHttp: <-- 200 OK http://www.spyur.am/en/companies/happy-print-printing-house/34896 (396ms, unknown-length body) 07-21 12:57:26.111 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 0 07-21 12:57:26.123 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=251KB, data=168KB 07-21 12:57:26.124 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=249KB, data=168KB 07-21 12:57:26.124 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 1024KB 07-21 12:57:26.173 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 1 07-21 12:57:26.177 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 2 07-21 12:57:26.186 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 3 07-21 12:57:26.226 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 4 07-21 12:57:26.232 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 5 07-21 12:57:26.238 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 6 07-21 12:57:26.244 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 7 07-21 12:57:26.265 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 8MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int) 07-21 12:57:26.437 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false 07-21 12:57:26.579 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 6MB to compile void android.view.ViewRootImpl.performTraversals() 07-21 12:57:27.754 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 0 07-21 12:57:27.761 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 1 07-21 12:57:27.765 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 2 07-21 12:57:27.772 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 3 07-21 12:57:27.784 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 4 07-21 12:57:27.788 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 5 07-21 12:57:27.792 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 6 07-21 12:57:27.796 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 7 07-21 12:57:29.889 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false 07-21 12:57:30.117 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false 07-21 12:57:30.756 1962-1962/com.incentive.yellowpages W/AutofillManager: Session 409360048 could not be restored 07-21 12:57:30.922 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=498KB, data=362KB 07-21 12:57:30.923 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=445KB, data=262KB 
+7
android animation android-animation android-transitions shared-element-transition
source share
3 answers

Here's the problem: you run Activity2 in portrait mode and return to Activity1 in landscape mode. But since you performed a change in orientation, the hierarchy of the Activity1 view is destroyed and created, so there is no longer a View originally started with the transition.

What you can do is reprogram the view from the old to the new using the Activity#setExitSharedElementCallback() API. There is little work to be done to deal with this situation, although that I have already described step by step in this answer.

The best choice for you is to check the Alex Lockwood application on github with the necessary functionality, it will be much easier for you to understand how to cope with the situation.

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setExitSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { if (we are coming back to Activity1) { View newSharedElement = findViewById(R.id.your_imageview); if (newSharedElement != null) { names.clear(); names.add("transition name"); sharedElements.clear(); sharedElements.put("transition name", newSharedElement); } } else { // we are leaving Activity1 } } }); } 

Basically, you clear the map and add a new pair of "transition name" to it. You can see how the if (we are coming back to Activity1) check is done here .


Here is a feature implemented in one of my applications .

enter image description here

+3
source share

I think the problem is with ImageView layouts, since the transition to the scene calculates the difference between the starting and ending positions, and then animates the difference, but here the final position was changed due to a change in orientation, you can try to recreate the final layout as soon. when you back off in case of a change in orientation, maybe I'm wrong, but I can only think about this scenario, can you provide the code for the same (it was too big to add as a comment, so you need to add in as an answer).

+3
source share

This seems to be happening only on Oreo. It can be played on API 26 emulator using the Google sample project, available here: https://github.com/googlesamples/android-ActivitySceneTransitionBasic/#readme

I was able to fix the problem in my application by adding the following:

 <item name="android:windowIsTranslucent">true</item> 

In the style of my activity.

+1
source share

All Articles