I know how to show full screen activity but it is not working in fragment activity ?
public class Dialog extends Fragment {
public Dialog() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialog, container, false);
}
}
Try to use DialogFragment
:
public class FullScreenDialogFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialog, container, false);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null) {
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}
}
In your question you have asked how to show full-screen fragment activity?
If you know how to make how to make an activity to full screen. You have to use the same way to make the FragmentActivity
full screen. Because FragmentActivity
is a subclass of Activity
.
↳ android.app.Activity
↳ android.support.v4.app.FragmentActivity
Also in your question, The class you have included is Fragment
, not FragmnetActivity
.
If you need to make your fragment full screen you have to make your hosting activity fullscreen.
use getActivity()
method to get hosting activity from the fragment. Then you can make the fragment fullscreen.
The answer by @shmakova worked for me, but then my colleague pointed out a simpler solution. It is enough to have the dialog's style inherit from a style, whose name ends with NoTitleBar.Fullscreen
and add a windowNoTitle
element. For example: In my Dialog:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AppCompatDialog(getActivity(), R.style.MyDialogStyle);
}
in src/main/res/values/styles.xml
:
<style name="MyDialogStyle" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
<item name="windowNoTitle">true</item>
</style>
There are several advantages of such an approach: you don't have to override onCreateDialog
and can have multiple styles.xml
instances depending on device features. For example, you can have your dialog extend to full screen only on the smaller screens.
try this solution
public class setWallpaperFragment extends DialogFragment {
public setWallpaperFragment() {
// Required empty public constructor
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int theme = android.R.style.Theme_Black_NoTitleBar_Fullscreen;
setStyle(DialogFragment.STYLE_NO_TITLE,theme);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.