Cómo configurar el diálogo de pantalla completa con el fragmento de diálogo
Estoy haciendo diálogo de pantalla completa con el fragmento de diálogo. Estoy correctamente mostrado el diálogo pero el problema está en su anchura y altura. No se puede mostrar el tamaño de pantalla completa. Quiero establecer el ancho y la altura con la acumulación de tamaño de pantalla completa como una actividad. Por favor, me guía cómo configurar el ancho de diálogo y la altura para acumular a tamaño de pantalla completa.
CustomeDialogFramgnet:
- AutoCompleteTextView permite sólo las opciones sugeridas
- Estilizar texto en un DialogFragment
- Android - DialogFragment con diseño que contiene fragmento
- Argumento DialogFragment y excepción nullpointer
- Android DialogFragment Redimensionamiento automático
public class CustomDialogFragment extends DialogFragment { /** The system calls this to get the DialogFragment's layout, regardless of whether it's being displayed as a dialog or an embedded fragment. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout to use as dialog or embedded fragment View rootView = inflater.inflate(R.layout.item_fragment, null, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); toolbar.setTitle("Dialog title"); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(android.R.drawable.ic_menu_close_clear_cancel); } return rootView; } /** The system calls this only when creating the layout in a dialog. */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // The only reason you might override this method when using onCreateView() is // to modify any dialog characteristics. For example, the dialog includes a // title by default, but your custom layout might not need it. So here you can // remove the dialog title, but you must call the superclass to get the Dialog. Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); return dialog; } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); getActivity().getMenuInflater().inflate(R.menu.alert_dialog_input, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_save) { // handle confirmation button click here return true; } else if (id == android.R.id.home) { // handle close button click here dismiss(); return true; } return super.onOptionsItemSelected(item); } }
item_fragment.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listView" android:text="zohaib"> </TextView> </LinearLayout> </android.support.design.widget.CoordinatorLayout>
- Pantalla completa DialogFragment
- DialogFragment no cambia el tamaño cuando se muestra el teclado
- DialogFragment animación de diseño y "Intentar destruir la ventana mientras dibuja!" Error
- ¿Cómo se muestra un DialogFragment de ancho completo?
- Android Cómo llamar a un método de fragmento de un botón DialogFragment botón positivo
- Android ShowDialog: IllegalStateException: No se puede realizar esta acción después de onSaveInstanceState
- OnContextItemSelected no se llama en un DialogFragment
- Iniciar un fragmento de diálogo en el botón de clic de un adaptador de base personalizado> getView
Crear un theme
en su style.xml
que se extiende desde Theme.AppCompat.Light.DarkActionBar
, algo como a continuación:
<style name="DialogFragmentTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:paddingRight">0dp</item> <item name="android:paddingLeft">0dp</item> <item name="android:layout_width">match_parent</item> <item name="android:windowNoTitle">true</item> </style>
y establecer el style
que creó al abrir el dialog
, algo como a continuación:
CustomDialogFragment mDialog = new CustomDialogFragment(); ... mDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragmentTheme); mDialog.show(getSupportFragmentManager(), "DialogFragment");
Crea un tema como este y añade a tu diálogo
<style name="ThemeDialog" parent="android:Theme.Holo.Dialog"> <item name="android:windowMinWidthMajor">100%</item> <item name="android:windowMinWidthMinor">100%</item> </style>
establecer esta línea después de crear el diálogo
getDialog().getWindow() .getAttributes().windowAnimations = R.style.ThemeDialog; WindowManager.LayoutParams wmlp = getDialog().getWindow().getAttributes(); wmlp.gravity = Gravity.FILL_HORIZONTAL; getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0)); getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
establecer esta línea después de crear el diálogo.
dialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
Si está creando DialogFragment
personalizado escriba esto en onCreate
de su DialogFragment
:
setStyle(DialogFragment.STYLE_NORMAL,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
referencia
Agregue esta línea en onCreate donde está inflando su diseño.
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
- LinearLayout con LayoutWeight no funciona
- ¿Cómo utilizar el dispositivo USB en Android Versión inferior como Android 2.2?