How to disable scrolling of AppBarLayout in CoordinatorLayout?

I’m not sure I got it, but I think you are looking for a DragCallback. The DragCallback interface allows to choose whether the sibling scrolling view should be controlled by scrolls onto the AppBarLayout. You can define one by calling: CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() { @Override public … Read more

SupportMapFragment.getmap() returns null

map takes some time to load, so you need to run your code in handler –> Handler handler = new Handler(); handler.postDelayed(new Runnable() @Override public void run() { GoogleMap googleMap = SupportMapFragment.newInstance(new GoogleMapOptions().zOrderOnTop(true)).getMap(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.map_content, fragment); ft.commit(); if(googleMap != null) { googleMap.addMarker(new MarkerOptions().position(result)).setVisible(true); // Move the camera instantly to location with a … Read more

Android – SupportMapFragment with GoogleMaps API 2.0 giving IllegalArgumentException

You can fix this, if you delete all nested fragments in onDestroyView(). Don’t know if it is a proper solution. public void onDestroyView() { super.onDestroyView(); Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); ft.remove(fragment); ft.commit(); } And inflating them as usual in onCreateView() public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.map, container, … Read more

How to show multiple markers on MapFragment in Google Map API v2?

I do it like this to show car positions on the map with markers of different colors: private void addMarkersToMap() { mMap.clear(); for (int i = 0; i < Cars.size(); i++) { LatLng ll = new LatLng(Cars.get(i).getPos().getLat(), Cars.get(i).getPos().getLon()); BitmapDescriptor bitmapMarker; switch (Cars.get(i).getState()) { case 0: bitmapMarker = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED); Log.i(TAG, “RED”); break; case 1: bitmapMarker = … Read more