Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to perform a custom animation on an Activity transition. The activity is supposed to slide smoothly upward instead of from the side. It works, but the view has a black bar (the same size as the status bar) on the top of the view. How can I get rid of the black bar? Here is the code I'm using:

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  overridePendingTransition(R.anim.upin, R.anim.upout);
  setContentView(R.layout.screen_login);
}

the animation upin:

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="100%" android:toYDelta="0%" android:duration="500" />
</set>

the animation upout:

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0%" android:toYDelta="0%" android:duration="500" />
</set>

EDIT: If I make all the Activities fullscreen it works perfectly. Of course, I don't WANT all the Activities to be fullscreen.

like image 323
Micah Hainline Avatar asked Apr 06 '11 20:04

Micah Hainline


2 Answers

Okay, found a way of doing this. In the activity that you are animating to, override your onCreate method. Before you call setContentView (I don't know if this is necessary, but it's the order in which I did it), add this code snippet:

ColorDrawable colorDrawable = new ColorDrawable( Color.TRANSPARENT );
getWindow().setBackgroundDrawable( colorDrawable );

This worked like a charm for me and I haven't seen any other side effects as of yet.

I actually ran into the same issue and stumbled upon your question. Hope you find this helpful.

  • groomsy

EDIT: Tested on Nexus One running 2.3.4

like image 194
groomsy Avatar answered Nov 15 '22 07:11

groomsy


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.

like image 22
Micah Hainline Avatar answered Nov 15 '22 07:11

Micah Hainline