2017-06-12 18 views
1

撥動我有對話框其中有一個EditText上得到由軟輸入keyboard.I've嘗試了所有的職位重疊的,我可以喜歡Android- AlertDialog不動鍵盤上方,當它在FullscreenActivity

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> 

回答

0

添加以下代碼清單

android:windowSoftInputMode="adjustResize" 

所以最終代碼是

+0

不工作,鍵盤仍然不會將對話框向上推。 – RootOnChair

+0

刪除清單中的keyboardHidden選項,並參見 – Anil

+0

也把這個對話框滾動視圖內 – Anil

相關問題