【问题标题】:Scroll dialog after keyboard is on键盘打开后滚动对话框
【发布时间】:2014-03-07 12:43:47
【问题描述】:

我有一些关于EditText 字段的对话框。当我想填写一些EditText 时,键盘已打开,我无法填写上面的某些字段。我应该关闭键盘,然后点击上面的EditText。如何在键盘打开时让我的对话框可滚动以避免关闭键盘?

【问题讨论】:

  • ScollView 中添加您的Layout
  • 我已经做到了,但它没有帮助......
  • @G 然后告诉我你的布局

标签: android android-layout android-dialog android-keypad


【解决方案1】:

试试:

dialog.getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

【讨论】:

    【解决方案2】:

    windowSoftInputMode 添加到清单中的活动

    <activity
    ...
        android:windowSoftInputMode="stateHidden|adjustResize">
    

    【讨论】:

    • 它没有帮助......它是一个对话框而不是一个活动页面
    【解决方案3】:

    xml(dialog_layout.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    
        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="10dp"
            android:elevation="5dp">
    
        </androidx.cardview.widget.CardView>
    
    </androidx.core.widget.NestedScrollView>
    

    java:

    final Dialog dialog = new Dialog(this);
                dialog.setContentView(R.layout.dialog_layout);
                dialog.setCanceledOnTouchOutside(false);
                Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        dialog.show();
    

    【讨论】:

      猜你喜欢
      • 2020-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 1970-01-01
      • 2020-08-21
      • 1970-01-01
      相关资源
      最近更新 更多