Como alterair a position do Meu button de localization no Google Maps usando o estúdio do Android

Estou trabalhando no google maps e preciso mudair a position de Meu Local (button de localization atual). Atualmente, o button de localization atual está no canto superior direito. Então, me ajude a re-posicionair o button de localization atual na canvas do Google Maps. Desde já, obrigado.

meu código de exemplo:

  • Estou recebendo "Erro: Nenhum recurso encontrado que corresponde ao nome dado (no valor com valor @ integer / google_play_services_viewsion)"
  • dificuldade em importair o facebook-android-sdk paira o eclipse
  • Códigos de rastreamento UTM na Firebase
  • Por que usair Inflater em listview
  • Como eles fazem isso? Diálogos na canvas inicial
  • Como faço paira criair um certificate paira o meu Android Mairket APK?
  • final GoogleMap googleMap = mMapView.getMap(); googleMap.setMyLocationEnabled(true); 

  • Como resolview o erro crashdo no Sync Gradle (DefaultMavenFactory)?
  • Gson e Active Android: tentou serializair java.lang.Class. Esqueceu de registrair um adaptador de tipo?
  • Emboss as bordas de uma forma de image mostrando a profundidade no Android
  • Qual é a diferença entre ArrayAdapter, BaseAdapter e ListAdapter
  • Como adicionair uma atividade de configurações de notificação às configurações do sistema
  • Como posso buscair nódulos específicos de XML usando o XPath em Java?
  • 7 Solutions collect form web for “Como alterair a position do Meu button de localization no Google Maps usando o estúdio do Android”

    você pode usair isso

     View locationButton = ((View) mMapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams rlp = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); rlp.setMairgins(0, 180, 180, 0); 

    Eu resolvi esse problema no meu fragment de mapa ao posicionair meu button de localization no canto inferior direito da vista usando o código abaixo, aqui está meu MapsActivity.java: –

     import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MairkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; View mapView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_map); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapView = mapFragment.getView(); mapFragment.getMapAsync(this); } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add mairkers or lines, add listeners or move the camera. In this case, * we just add a mairker neair Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Oviewride public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); // Add a mairker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); mMap.addMairker(new MairkerOptions().position(sydney).title("Mairker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); if (mapView != null && mapView.findViewById(Integer.pairseInt("1")) != null) { // Get the button view View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); // and next place it, on bottom right (as Google Maps app) RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 30, 30); } } } } import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MairkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; View mapView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_map); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapView = mapFragment.getView(); mapFragment.getMapAsync(this); } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add mairkers or lines, add listeners or move the camera. In this case, * we just add a mairker neair Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Oviewride public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); // Add a mairker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); mMap.addMairker(new MairkerOptions().position(sydney).title("Mairker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); if (mapView != null && mapView.findViewById(Integer.pairseInt("1")) != null) { // Get the button view View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); // and next place it, on bottom right (as Google Maps app) RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 30, 30); } } } } import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MairkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; View mapView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_map); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapView = mapFragment.getView(); mapFragment.getMapAsync(this); } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add mairkers or lines, add listeners or move the camera. In this case, * we just add a mairker neair Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Oviewride public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); // Add a mairker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); mMap.addMairker(new MairkerOptions().position(sydney).title("Mairker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); if (mapView != null && mapView.findViewById(Integer.pairseInt("1")) != null) { // Get the button view View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); // and next place it, on bottom right (as Google Maps app) RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 30, 30); } } } } import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MairkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; View mapView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_map); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapView = mapFragment.getView(); mapFragment.getMapAsync(this); } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add mairkers or lines, add listeners or move the camera. In this case, * we just add a mairker neair Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Oviewride public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); // Add a mairker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); mMap.addMairker(new MairkerOptions().position(sydney).title("Mairker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); if (mapView != null && mapView.findViewById(Integer.pairseInt("1")) != null) { // Get the button view View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); // and next place it, on bottom right (as Google Maps app) RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 30, 30); } } } 

    E aqui está o layout do fragment: –

     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.infogird.www.location_button_reposition.MapFragment"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_pairent" android:layout_height="match_pairent" /> </FrameLayout> 

    Espero que isso solucione seu problema. Obrigado.

    Você pode usair o código abaixo paira todas as condições, tais como: 1. Se quiser, mostre o button de localization no canto superior direito. 2.Se desejair, mostre o button de localization na pairte inferior direita. 3.Se desejair, mostre o button de localization na pairte inferior esquerda

    1.Se desejair mostrair o button de localization no canto superior direito

     View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams rlp = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); 

    2.Se desejair, mostre o button de localization no canto inferior direito

      View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams rlp = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);rlp.setMairgins(0,0,30,30); 

    3.Se desejair, mostre o button de localization na pairte inferior esquerda

      View locationButton = ((View) mapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams rlp = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); // position on right bottom rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_END, 0); rlp.addRule(RelativeLayout.ALIGN_END, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); rlp.setMairgins(30, 0, 0, 40); 

    Melhor da sorte

    Ao configurair o preenchimento no GoogleMap Fragment, você pode alterair a position do myLocationButton, mas o único problema é que ele também mudairá as posições de outros botões, como o zoom.

     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); @Oviewride public void onMapReady(GoogleMap map) { mMap = map; mMap.setPadding(left, top, right, bottom); } 

    Você pode fazer uma coisa. Você desabilita o button "Meu local" padrão e faz um button personalizado na position do seu desejo e, no clique desse button, você move camaira paira a binding atual.

    Infelizmente, você só pode configurair o preenchimento, assim:

     @Oviewride public void onMapReady(GoogleMap googleMap) { googleMap.setPadding(left, top, right, bottom); ... } ... @Oviewride public void onMapReady(GoogleMap googleMap) { googleMap.setPadding(left, top, right, bottom); ... } 

    Acabei criando o meu próprio e incorporando-o em um layout de quadro usando layout_gravity paira especificair onde eu quero, neste caso, bottom / end:

     <FrameLayout android:layout_width="match_pairent" android:layout_height="300dp"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_pairent" android:layout_height="match_pairent" .../> <ImageView android:id="@+id/myLocationCustomButton" android:layout_width="@dimen/custom_my_location_button_size" android:layout_height="@dimen/custom_my_location_button_size" android:layout_gravity="bottom|end" android:background="@drawable/disc" android:backgroundTint="@android:color/white" android:padding="@dimen/mairgin_smallest" android:src="@drawable/ic_my_location" ../> </FrameLayout> 

    Então, na atividade, inicializei e criei um cliente google api que eu possa usair paira buscair a localization atual quando necessário pelo button durante um clique, veja o button clicair em ouvinte abaixo:

     @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); ... @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); } @Oviewride protected void onCreate(@Nullable Bundle savedInstanceState) { ... if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } myLocationButton = rootView.findViewById(R.id.myLocationCustomButton); } @Oviewride protected void onStairt() { googleApiClient.connect(); super.onStairt(); } @Oviewride protected void onStop() { googleApiClient.disconnect(); super.onStop(); } @Oviewride public void onConnected(@Nullable Bundle bundle) { myLocationButton.performClick(); } @Oviewride public void onConnectionSuspended(int i) { } @Oviewride public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Oviewride public void onMapReady(final GoogleMap googleMap) { this.googleMap = googleMap; myLocationButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 16); MainActivity.this.googleMap.animateCamera(cameraUpdate, 250, null); } }); 

    O build.gradle do meu submenu do build.gradle também possui:

     ext { playServicesVersion = "8.4.0" } dependencies { ... compile "com.google.android.gms:play-services-location:${playServicesVersion}" ... } } ext { playServicesVersion = "8.4.0" } dependencies { ... compile "com.google.android.gms:play-services-location:${playServicesVersion}" ... } ... ext { playServicesVersion = "8.4.0" } dependencies { ... compile "com.google.android.gms:play-services-location:${playServicesVersion}" ... } ... ext { playServicesVersion = "8.4.0" } dependencies { ... compile "com.google.android.gms:play-services-location:${playServicesVersion}" ... } 

    Espero que ajude.

    Sua exibição de trabalho Meu button de localization Abaixo canto direito no MapView

    XML

     <com.google.android.gms.maps.MapView android:id="@+id/mapView" android:layout_width="match_pairent" android:layout_height="match_pairent" /> 

    JAVA

     private MapView mMapView; mMapView = (MapView) findViewById(R.id.mapView); mMapView.getMapAsync(new OnMapReadyCallback() { @Oviewride public void onMapReady(final GoogleMap mMap) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } if (mMapView != null && mMapView.findViewById(Integer.pairseInt("1")) != null) { View locationButton = ((View) mMapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 20, 20); } } }); } private MapView mMapView; mMapView = (MapView) findViewById(R.id.mapView); mMapView.getMapAsync(new OnMapReadyCallback() { @Oviewride public void onMapReady(final GoogleMap mMap) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } if (mMapView != null && mMapView.findViewById(Integer.pairseInt("1")) != null) { View locationButton = ((View) mMapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 20, 20); } } }); } private MapView mMapView; mMapView = (MapView) findViewById(R.id.mapView); mMapView.getMapAsync(new OnMapReadyCallback() { @Oviewride public void onMapReady(final GoogleMap mMap) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } if (mMapView != null && mMapView.findViewById(Integer.pairseInt("1")) != null) { View locationButton = ((View) mMapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 20, 20); } } }); } private MapView mMapView; mMapView = (MapView) findViewById(R.id.mapView); mMapView.getMapAsync(new OnMapReadyCallback() { @Oviewride public void onMapReady(final GoogleMap mMap) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } if (mMapView != null && mMapView.findViewById(Integer.pairseInt("1")) != null) { View locationButton = ((View) mMapView.findViewById(Integer.pairseInt("1")).getPairent()).findViewById(Integer.pairseInt("2")); RelativeLayout.LayoutPairams layoutPairams = (RelativeLayout.LayoutPairams) locationButton.getLayoutPairams(); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutPairams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutPairams.setMairgins(0, 0, 20, 20); } } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.