Unbalanced Snackbar

3

I have a snackbar that runs when I click on a marker, the problem I have is the position where the snackbar opens:

is interrupted with the android action buttons and my idea is to move it a little higher, then the code I'm using

map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                View v1 = getWindow().getDecorView().getRootView();
                Snackbar.make(v1,"Nombre de la ciclovía: "+marker.getTitle()+ System.getProperty ("line.separator")+"Caracteristicas de la vía: "+marker.getSnippet(),Snackbar.LENGTH_INDEFINITE).show();
                return false;
            }
        });

here is the layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/content_main"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.ciclomapp.ciclomapp.ciclomapp.MainActivity"
    tools:showIn="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light">

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>
    
asked by zhet 08.12.2016 в 21:18
source

1 answer

2

Instead of getting the "root" view by:

View v1 = getWindow().getDecorView().getRootView();

get the container that in your case is a RelativeLayout with id content_main :

  View v1 = (RelativeLayout)findViewById(R.id.content_main);
  Snackbar.make(v1,"Nombre de la ciclovía: !!!!!!!!",Snackbar.LENGTH_INDEFINITE).show();
    
answered by 08.12.2016 / 21:35
source