MapFragment gets a dark overlay when used in DialogActivity

前端 未结 5 1140
故里飘歌
故里飘歌 2020-12-24 08:39

I\'m trying to show a MapFragment of the Android Maps v2 API in an Activity with the @android:style/Theme.DeviceDefault.Light.Di

5条回答
  •  不思量自难忘°
    2020-12-24 08:50

    To add on to Audrel's solution, one can dynamically un-dim the dialog's window whenever the map is shown and dim it back when the map is gone (e.g. when your dialog has multiple pages, one of them is a map):

    private float mDimAmount;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WindowManager.LayoutParams params = getWindow().getAttributes();
        mDimAmount = params.dimAmount; // remember original dim amount
        ...
    }
    
    private void undim() {
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.dimAmount = 0.0f;
        getWindow().setAttributes(params);
    }
    
    private void dim() {
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.dimAmount = mDimAmount;
        getWindow().setAttributes(params);
    }
    

    Still just another workaround rather than tackling the root cause...

提交回复
热议问题