How to Remove Black Background Between Start New Activity During Slide_Left Animation

How to remove Black background between start new activity during slide_left animation?

set the theme of that activity as transluscent in manifest file

android:theme="@android:style/Theme.Translucent"

so your code will be something like this

<activity android:name=".AdActivity"
android:theme="@android:style/Theme.Translucent" />

Activity transition black screen

What I always do is to start an activity(any way you want, ways are listed here).

I use slide transitions using these two files:

slide_out_left.xml:

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:toXDelta="-100%p" />
</set>

slide_in_right.xml:

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>

Then I start an activity like this(this is java):

startActivity(MainActivity.this, SecondActivity.class);
overridePendingTransition(R.anim.slide_in_right.xml, R.anim.slide_in_left.xml);
finish();

Using this, the activity exits giving way to the new one smoothly from right to left.

For the black screen, set the theme of that activity as translucent in the AndroidManifest.xml file

android:theme="@android:style/Theme.Translucent"

so your code will be something like this

<activity android:name=".Activity"
android:theme="@android:style/Theme.Translucent" />

Answer for the black screen taken from: https://stackoverflow.com/a/6468734/9819031

How do I get rid of this black bar during animation?

Okay, I tried a few things, like making the deltas relative to the parent, etc. I think the core problem is that the activity has extra space at the top, which is that black bar. There's not really anything to be done about it as far as I can see except to pull it out of the activity and make it a view.

Placing that view into a ViewAnimator and then setting the in and out transitions to those I already listed works like a charm. I'm fairly convinced that there is no other way to do this. If anyone ever figures one out, let me know, but this solves my problem.

Smooth transition between activities without black screen

One of the simplest way is to move all the expensive (time-consuming) processing from your activity's onCreate and onStart method to onResume mthod. By this, your newly launched activity will be visible right after its launched but then will take a little extra to make it available for user to interact. Further, I would suggest you to move all the heavy lifting in AsyncTask for smoother UI experience.



Related Topics



Leave a reply



Submit