I am trying to write an app for searching nearest places of interest, for example restaurants. My problem is that despite seemingly proper coding, the button that should move the map view to the current location does not appear. Here's my code, an excerpt from onMapReady function:
if (mapView != null && mapView.findViewById(Integer.parseInt("1")) != null) {
//View locationButton = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("4"));
View locationButton = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
layoutParams.setMargins(0, 0, 30, 30);
}
I have tried looking for answers, but most of already given answers concern problems with just positioning and not not appearing at all. Android: Google Maps API - Change position of maps toolbar This question concerns the same problem, but in my application permissions are given on runtime, at least I think they are (There's a separate activity for grating permissions when the aplication is started for the first time). My location button is not showing in map fragment