问题
When I set the style of a dialog fragment, the android is allowing to take the screen shot of dialog fragment, but after removing the style it works.
Below is the code of dialog fragment's onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light);
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setCancelable(false);
}
Has any one else faced a similar issue before?
回答1:
AFAICT, using FLAG_SECURE
on the hosting activity is insufficient to make a DialogFragment
secure.
In addition to using FLAG_SECURE
for the activity, call getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
on the Dialog
that you create in onCreate()
of the DialogFragment
, before you return that Dialog
.
来源:https://stackoverflow.com/questions/32440679/flag-secure-not-working-on-dialogfragment-with-style-as-dialogfragment-style-no