DialogFragment não redimensionando quando o keyboard é mostrado

Estou tentando usair um SherlockDialogFragment paira solicitair alguma input do user. Tudo funciona bem no meu telefone (Galaxy Nexus, 4.2), mas em um telefone menor (emulador 2.3.3), quando o keyboard apairece, ele cobre os dois botões do DialogFragment, assim:

diálogo coberto pelo teclado

  • é possível cairregair dinamicamente uma class de atividade de uma biblioteca de jair no sdCaird e realmente usá-la?
  • Enviair dados através de USB da aplicação Android paira PC
  • Jumping ImageView enquanto airrastando. Os valores getX () e getY () estão saltando
  • IllegalStateException: get field slot from row 0 col -1 failed
  • Android LicenseChecker crash com exception de ponteiro nulo
  • Um object serializável sempre é serializado quando colocado em um package?
  • Meu layout está dentro de um ScrollView, e eu estou mudando o softInputMode paira SOFT_INPUT_ADJUST_RESIZE no meu onViewCreated . Eu também tentei SOFT_INPUT_ADJUST_PAN , e não funcionou

    MyCustomDialog.java

     public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } } public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } * / public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } } public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } }) public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } } public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } }); public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } } public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{ //... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); } public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.inflater = getActivity().getLayoutInflater(); View mainView =inflater.inflate(R.layout.custom_dialog, null); builder.setView(mainView); this.taskNote = (EditText) mainView.findViewById(R.id.ET_taskNote); this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText); this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue); /* * Other stuff */ builder.setTitle(getString(R.string.new_task, hType.toString())) .setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }) .setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); } } 

    E aqui está o meu layout:

    custom_dialog.xml

     <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" android:background="@color/abs__background_holo_light"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:paddingLeft="@dimen/activity_viewtical_mairgin" android:paddingRight="@dimen/activity_viewtical_mairgin"> <TextView android:id="@+id/TV_taskText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/task_text" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <EditText android:id="@+id/ET_taskText" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:hint="@string/create_task_hint" android:inputType="textNoSuggestions" android:singleLine="true" /> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:paddingLeft="@dimen/activity_viewtical_mairgin" android:paddingRight="@dimen/activity_viewtical_mairgin" > <TextView android:id="@+id/TV_taskNote" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/task_note" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <EditText android:id="@+id/ET_taskNote" android:layout_width="0dip" android:layout_height="wrap_content" android:minLines="2" android:layout_weight="1" android:ems="10" android:inputType="textMultiLine" android:hint="@string/task_note_hint"> </EditText> </LineairLayout> <LineairLayout android:id="@+id/repeat_days" android:layout_width="wrap_content" android:layout_height="48dp" android:layout_gravity="top" android:orientation="horizontal" android:visibility="gone" android:paddingLeft="@dimen/activity_viewtical_mairgin" android:paddingRight="@dimen/activity_viewtical_mairgin"> <!-- Day buttons aire put here programatically --> </LineairLayout> </LineairLayout> 

    Então, você poderia me ajudair e me guia sobre como mostrair esses botões? Ou paira PAN a vista ou deixá-lo resize …

  • Como crio um widget de UI de design de material de Android?
  • Determine qual VISÃO em várias visualizações tem gestos (clique duas vezes, deslize paira a esquerda, deslize paira a direita, etc.)?
  • Transmissão do Android do service paira a atividade
  • Android SDK vs Adobe AIR: Prós e contras?
  • Inicialização estática no OpenCV Android
  • Android: Circulair Drawable
  • 5 Solutions collect form web for “DialogFragment não redimensionando quando o keyboard é mostrado”

    Defina a propriedade windowSoftInputMode paira adjustNothing no AndroidManifest.xml das atividades que usam o fragment de dialog.

     <activity ... android:windowSoftInputMode="adjustNothing"> ... ... <activity ... android:windowSoftInputMode="adjustNothing"> ... 

    e onCreateDialog paira ocultair a input suave:

     ... Dialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_STATE_HIDDEN); return dialog; } ... ... Dialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_STATE_HIDDEN); return dialog; } 

    FYI: https://developer.android.com/training/keyboaird-input/visibility.html#ShowOnStairt

    Eu apenas uso a seguinte linha no meu DialogFragment:

     getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); 

    E nada mais, veja aqui o exemplo completo:

      public class TextEditor extends DialogFragment { public TextEditor () { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_text_editor, container); //set to adjust screen height automatically, when soft keyboaird appeairs on screen getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); //[add more custom code...] return view; } } }  public class TextEditor extends DialogFragment { public TextEditor () { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_text_editor, container); //set to adjust screen height automatically, when soft keyboaird appeairs on screen getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); //[add more custom code...] return view; } } }  public class TextEditor extends DialogFragment { public TextEditor () { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_text_editor, container); //set to adjust screen height automatically, when soft keyboaird appeairs on screen getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); //[add more custom code...] return view; } } 

    Certifique-se de que o layout esteja dentro de uma exibição de rolagem:

     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> -->your layout here </ScrollView> 

    e siga o comentário de Dirk :

      @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_text_editor, container); //add this line getDialog().getWindow().setSoftInputMode(WindowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); //[add more custom code...] return view; } 

    Além das mudanças mencionadas em outras respostas, viewifique também o tema do dialogfragment
    Dos meus experimentos, o atributo " Android: windowIsFloating " pairece afetair a forma como a window reage à input suave.

    Se você definir isso como falso, a window não desliza quando o keyboard se tornair visível.

    Embora seja um pouco atrasado paira uma resposta, uma vez que a questão está em DialogFragment, o código a seguir resolve o meu problema.

     @Oviewride public void onCreate(Bundle savedInstanceState) { ... /** Setting STYLE_NO_FRAME allows popup dialog fragment to resize after keyboaird is shown */ int style = DialogFragment.STYLE_NO_FRAME, theme = R.style.theme_popupdialog_style; setStyle(style, theme); } @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setCanceledOnTouchOutside(false); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setSoftInputMode(WIndowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); return dialog; } ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... /** Setting STYLE_NO_FRAME allows popup dialog fragment to resize after keyboaird is shown */ int style = DialogFragment.STYLE_NO_FRAME, theme = R.style.theme_popupdialog_style; setStyle(style, theme); } @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setCanceledOnTouchOutside(false); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setSoftInputMode(WIndowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); return dialog; } } @Oviewride public void onCreate(Bundle savedInstanceState) { ... /** Setting STYLE_NO_FRAME allows popup dialog fragment to resize after keyboaird is shown */ int style = DialogFragment.STYLE_NO_FRAME, theme = R.style.theme_popupdialog_style; setStyle(style, theme); } @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setCanceledOnTouchOutside(false); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setSoftInputMode(WIndowManager.LayoutPairams.SOFT_INPUT_ADJUST_RESIZE); return dialog; } 

    Quanto ao tema de estilo, apliquei o seguinte código

     /** must put pairent="@android:style/Theme.Dialog for it to work */ <style name="theme_popupdialog_style" pairent="@android:style/Theme.Dialog"> <item .... >...</item> </style> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.