I am working on image transition effect while two activities using the new shared elements from lollipop OS. It's working but I get a distorted white blinking on the screen during the transition and I can't find how to implement a solution for this issue.
After doing lots of R&D, i found Same kind of issue here :
To implement a blink effect on the image transition between Android activities, you can use the following code:
Code snippet
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
// Get the image from the first activity
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.image);
// Create a Transition object
Transition transition = new Transition();
// Set the transition duration
transition.setDuration(1000);
// Set the transition effect
transition.setInterpolator(new AccelerateDecelerateInterpolator());
// Set the transition image
transition.addTarget(imageView);
// Start the transition
transition.start();
// Start the second activity
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
}
}
This code will first get the image from the first activity. Then, it will create a
Transition object and set its duration and interpolator. Next, it will set the
Transition object's image to the imageView. Finally, it will start the
Transition object and start the second activity.
The Transition object will cause the imageView to blink for 1000 milliseconds before starting the second activity.
To use this code, you need to add the following dependency to your project's
build.gradle file:
Aryan Kumar
02-Jul-2023To implement a blink effect on the image transition between Android activities, you can use the following code:
Code snippet
This code will first get the image from the first activity. Then, it will create a
Transition
object and set its duration and interpolator. Next, it will set theTransition
object's image to theimageView
. Finally, it will start theTransition
object and start the second activity.The
Transition
object will cause theimageView
to blink for 1000 milliseconds before starting the second activity.To use this code, you need to add the following dependency to your project's
build.gradle
file:Code snippet
You also need to add the following code to your project's
activity_main.xml
file:Code snippet
This code will add an
ImageView
widget to theactivity_main.xml
file. TheImageView
widget will be used to display the image that is being blinked.