Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation not working On Google Map Android

I am creating an Friend tracker like app . It consist of an Animation describe below: When clicking on marker , an sliding up like menu from bottom of screen comes on half of screen and clicking marker again it slide down .

Slide_up animation image on marker click :

enter image description here

I want : slide down menu when clicking anywhere on Map . Means when menu is up , i want it to be down either clicking marker or anywhere on map . Please help me achieving it .

code for Animation which call on marker click :

public void animation(Marker m, LatLng loc) {
        Fragment f = getFragmentManager().findFragmentByTag(LIST_FRAGMENT_TAG);

//        googleMap.animateCamera(CameraUpdateFactory.zoomTo(10));
        googleMap.setMyLocationEnabled(true);

        googleMap.getUiSettings().setAllGesturesEnabled(true);
        googleMap.getUiSettings().setRotateGesturesEnabled(false);

        if (f != null) {
            getFragmentManager().popBackStack();
        } else {
            getFragmentManager()
                    .beginTransaction()
                    .setCustomAnimations(R.anim.slide_up,
                            R.anim.slide_down,
                            R.anim.slide_up,
                            R.anim.slide_down)
                    .add(R.id.list_fragment_container, BaseMapSlidingFragment
                                    .instantiate(this, BaseMapSlidingFragment.class.getName()),
                            LIST_FRAGMENT_TAG
                    )
                    .addToBackStack(null).commit();

            googleMap.getUiSettings().setAllGesturesEnabled(false);

        }}

Animation files : slide_down.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:propertyName="yFraction"
            android:valueType="floatType"
            android:valueFrom="0.58"
            android:valueTo="1.0"
            android:duration="@android:integer/config_mediumAnimTime"/>
    <objectAnimator
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:propertyName="alpha"
            android:valueType="floatType"
            android:valueFrom="1"
            android:valueTo="0"
            android:duration="@android:integer/config_mediumAnimTime"/>
</set>

slide_up.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:propertyName="yFraction"
            android:valueType="floatType"
            android:valueFrom="1.0"
            android:valueTo="0.58"
            android:duration="@android:integer/config_mediumAnimTime"/>
    <objectAnimator
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:propertyName="alpha"
            android:valueType="floatType"
            android:valueFrom="0.58"
            android:valueTo="1.0"
            android:duration="@android:integer/config_mediumAnimTime"/>
</set>
like image 247
young_08 Avatar asked Nov 26 '25 21:11

young_08


1 Answers

You should have an onClickListener on the Layout by clicking on which your menu should go down.

Then make a Boolean variable(false if menu is not open and true when menu is showing) which will record the status of menu(whether menu is open or closed).

Then you just need to do following two things:

  1. when clicked on FrameLayout check if the menu is open or not by checking Boolean variable value.

  2. If Menu is showing then call animation method there too.

I guess this problem should be solved now.

Let me know if this is not working by commenting below.

like image 176
Sangeeta Avatar answered Nov 29 '25 18:11

Sangeeta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!