簡體   English   中英

在FullscreenActivity中切換時,Android- AlertDialog不會在鍵盤上方移動

[英]Android- AlertDialog doesn't move above keyboard when it toggle in FullscreenActivity

我有一個對話框,它有一個EditText與軟輸入鍵盤重疊。我已經嘗試了我喜歡的所有帖子

 dialog.getWindow().setSoftInputMode(ADJUST_RESIZE)

並為對話框設置主題,但它們都不起作用。 我認為我的全屏活動已經改變了一些東西,但我不知道它是什么

 View layout= LayoutInflater.from(context).inflate(R.layout.add_bookmark_dialog_layout,null);
    final EditText note=(EditText)layout.findViewById(R.id.bookmark_note);
    TextView page= (TextView)layout.findViewById(R.id.bookmark_page);
    TextView file=(TextView)layout.findViewById(R.id.bookmark_file);
    page.setText(String.valueOf(currentPage));
    file.setText(fileName);
    AlertDialog.Builder builder=new AlertDialog.Builder(context).setView(layout).setTitle("Add New Bookmark").setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Bookmark newBookmark= db.addBookmark(currentPage,note.getText().toString(),fileName);
            adapter.add(newBookmark);
        }
    }).setNegativeButton("Cancel",null);
    AlertDialog dialog=builder.create();
   //Not working : dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    dialog.show();

這是我的AndroidManifest.xml

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity" android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"  />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
//where dialog pop up
    <activity
        android:name=".ReadingActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/title_activity_reading"
        android:parentActivityName=".MainActivity"
        android:theme="@style/FullscreenTheme"></activity>
</application>

在清單中添加以下代碼

android:windowSoftInputMode="adjustResize"

所以最終的代碼是

 <activity
        android:name=".ReadingActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/title_activity_reading"
        android:windowSoftInputMode="adjustResize"
        android:parentActivityName=".MainActivity"
        android:theme="@style/FullscreenTheme"></activity>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM