Android v2 MapFragment shaking when scrolling in Scrollview

前端 未结 2 1157
忘了有多久
忘了有多久 2021-01-06 21:53

I am using the SupportMapFragment to display a static map in a ScrollView. I do not like to move / zoom the Map, just showing where the location is.

When I am scrol

2条回答
  •  伪装坚强ぢ
    2021-01-06 22:27

    Try using this class, it should look better at least when scrolling right and left in our scrollview:

    public class TransparentSupportMapFragment extends SupportMapFragment {
        public TransparentSupportMapFragment() {
    
            super();
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup view, Bundle savedInstance) {
    
            View layout = super.onCreateView(inflater, view, savedInstance);
            FrameLayout frameLayout = new FrameLayout(getActivity());
            frameLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
            ((ViewGroup) layout).addView(frameLayout, new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            return layout;
        }
    }
    

提交回复
热议问题