How to translate a view, but keep its original starting position

I'm animating the view so that the bottom navigation bar is hidden when the keyboard appears.

My problem is that I can translate the bottom navigation bar, and the main “message area” can follow it, but a space forms at the top of the “message area”. Is there a way to translate, but save the top of the “message area” according to the action bar?

Here is an example of the animation and break that forms: enter image description here

My animation code is as follows:

if (lowerNavigationBar.getVisibility() == View.VISIBLE) {

    lowerNavigationBar.animate()
            .translationY(lowerNavigationBar.getHeight()).setDuration(1000).start();
    viewPager.animate()
            .translationY(lowerNavigationBar.getHeight()).setDuration(1000).start();
    lowerNavigationBar.setVisibility(View.INVISIBLE);   

}
else{

    lowerNavigationBar.setVisibility(View.VISIBLE);
    lowerNavigationBar.animate()
            .translationY(0).setDuration(1000).start();
    viewPager.animate()
            .translationY(0).setDuration(1000).start();

}
0
source share
1 answer

, , , , .

, ValueAnimators , . , , .

0

Source: https://habr.com/ru/post/1673595/


All Articles