Skip to content
Advertisement

How Can I make a windows to pop up from the bottom of the screen?

I have a Map, with markers on the Gas Stations around my location. When I click on them, I want a window to raise from the bottom of the screen (and go only half through the Map Screen) where I want to display info about that gas station. How do I do this window coming from the bottom of the screen? Animation?

enter image description here

Advertisement

Answer

Declarations :

  Animation slideup, slidedown;
  LinearLayout bottomLay;

Initializations:

  slideup = AnimationUtils.loadAnimation(this, R.anim.slide_up);
  slidedown = AnimationUtils.loadAnimation(this, R.anim.slide_down);
  bottomLay = findViewById(R.id.bottomLay); //your bottom view

start the animation :

public void startSlideDown() {
       bottomLay.startAnimation(slidedown); // down 
}

or

public void startSlideUp() {
      bottomLay.startAnimation(slideup);  // up
}

slide_down.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="0"
        android:toYDelta="100%p" />

</set>

slide_up.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_mediumAnimTime"
    android:fromYDelta="100%p"
    android:toYDelta="0%p" />
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement