I am trying to pretend (Linear view with some buttons in R.id.playerControl ) to insert and delete depending on the context of other events in the activity.
For this purpose, I have a selectMediaItem method that should show or hide the view when the user selects or deselects the item accordingly.
I am new to animation in android, and I am having problems with its operation for two reasons:
The view remains on the screen outside the animation time, so when he has finished crawling, he comes back - when he is asked to move, he jumps out to go back.
Permanent black space appears on the screen when the view disappears. I would like the view to fill the space when it is visible, and GONE when not. To do this, I would like the layout to also change with the animation, so that it seems to push away other things.
My code is:
protected void selectMediaItem( ItemHandle item ) { if (item != null) { if (toPlay == null) { View playerControl = findViewById(R.id.playerControl); Animation slideInAdmination = AnimationUtils.loadAnimation(this, R.anim.slide_in); playerControl.startAnimation(slideInAdmination); } } else { if (toPlay != null) { View playerControl = findViewById(R.id.playerControl); Animation slideInAdmination = AnimationUtils.loadAnimation(this, R.anim.slide_out); playerControl.startAnimation(slideInAdmination); } } toPlay = item; }
slide_in.xml
<translate android:duration="1000" android:fromYDelta="100%p" android:toYDelta="0" /> </set>
Is there an easy way to move the view in place and bring it back out?
Philip couling
source share