相关疑难解决方法(0)

键盘显示时,DialogFragment没有调整大小

我正在尝试使用a SherlockDialogFragment来询问用户的一些输入.我的手机上的一切正常(Galaxy Nexus,4.2),但在较小的手机(模拟器2.3.3)上,当键盘出现时,它覆盖了DialogFragment的两个按钮,如下所示:

键盘覆盖的对话框

我的布局在ScrollView中,我正在将softInputMode更改为SOFT_INPUT_ADJUST_RESIZEmy onViewCreated.我也试过了SOFT_INPUT_ADJUST_PAN,但没用

MyCustomDialog.java

public class AddTaskDialog extends SherlockDialogFragment implements OnDateSetListener{
//...
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.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 …
Run Code Online (Sandbox Code Playgroud)

android android-view android-dialogfragment actionbarsherlock

19
推荐指数
7
解决办法
2万
查看次数