나는 시간 동안 인터넷 검색과 셀 수없이 많은 일들을 시도했지만 난 그냥이 동작하지 않습니다 ...상태 표시 줄/탐색 모음과 mantain 상태 표시 줄 색상이 겹치지 않으면 서 DialogFragment를 전체 화면으로 만드는 방법은 무엇입니까?
이 MyFragment.java
입니다했습니다 :
public class MyFragment extends DialogFragment {
public MyFragment() {
// Required empty public constructor
}
public static MyFragment newInstance() {
MyFragment newFragment = new LoginDialogFragment();
newFragment.setCancelable(false);
return newFragment;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new Dialog(getActivity(), R.style.MyAppTheme_Dialog);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Window window = getDialog().getWindow();
if (window != null) {
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
window.setWindowAnimations(R.style.MyAppTheme_Dialog);
}
}
}
그리고 이것은 styles.xml
입니다 :
<style name="MyAppTheme" parent="PreferenceFixTheme.Light.NoActionBar">
<item name="android:windowBackground">@color/background</item>
<item name="android:colorBackground">@color/background</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="preferenceCategory_marginBottom">0dp</item>
</style>
<style name="MyAppTheme.Dialog">
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>
거의 예상대로 작동합니다 ... 유일한 문제는 window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
을 호출하여 상태/탐색 모음을 제외한 전체 화면을 채우면 상태 표시 줄의 색이 검정으로 바뀌는 것입니다. 대화 상자를 닫으면 colorPrimaryDark
으로 다시 바뀝니다.
해당 window.setLayout(...)
행을 제거하면 상태 표시 줄에 colorPrimaryDark
이 유지되지만 대화 상자 크기가 기본값 (화면 중간의 작은 사각형)이됩니다.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().setStatusBarColor(ContextCompat.getColor(getActivity, R.color.primary_dark));
}
이것은 colorPrimaryDark
에 상태 표시 줄의 색상을 설정하지만이 상태 및 탐색 모음을 모두 겹치는 : 나는 window.setLayout(...)
전화 같은 장소에서
상태 표시 줄과 탐색 모음을 겹치지 않고 전체 화면을 가져올 수 없으며 상태 표시 줄에 colorPrimaryDark
을 유지하십시오.
동일한 문제로 몇 가지 질문을했지만 제대로 작동하지 못했습니다. 둘 다 허용 된 대답이 없다 :
- Fullscreen DialogFragment with translucent StatusBar
- Android full screen dialog fragment like calendar app
DialogFragment 여야합니까? 활동이 효과가 있습니까? – Karakuri
당신은 재정의 한 dialogfragment를 시도했습니다. 나는 코드를 가지고있다. 나는 당신의 요구를 만족시킬 것인지 아닌지를 모른다. 어떤 방법 으로든 내가 코드를 게시 할 것입니다. 시도 해봐. – Noorul
왜 대화 상자를 대화 상자가 아니게하려고합니까? 당신은 잘못된 추상화를 사용하는 것 같습니다. – ianhanniballake