2017-08-06 94 views
1

我想在我的android应用程序之一使用自定义对话框编辑文本。我想要在键盘上显示对话。我在键盘下面隐藏了一半的对话。我无法找到解决方案。让我知道,如果这里的专家可以帮助解决这个难题。键盘自定义对话Android

我对话的Java代码就像下面

final Dialog dialog = new Dialog(NameArt.this,R.style.Theme_Dialog); 
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    dialog.setContentView(R.layout.lyt_dialog_updatename); 
    //dialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); 
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 

和XML是像下面

<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="wrap_content"> 
 

 
    <EditText 
 
     android:id="@+id/edstikertext" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:gravity="center" 
 
     android:layout_above="@+id/btncancel" 
 
     android:hint="Enter text hear" /> 
 

 
    <Button 
 
     android:id="@+id/btncancel" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:layout_alignParentLeft="true" 
 
     android:layout_alignParentStart="true" 
 
     android:layout_marginRight="5dp" 
 
     android:layout_alignParentBottom="true" 
 
     android:layout_marginEnd="5dp" 
 
     android:background="@drawable/boder" 
 
     android:layout_marginTop="5dp" 
 
     android:text=" Cancel " /> 
 

 
    <Button 
 
     android:background="@drawable/boder" 
 
     android:layout_alignParentRight="true" 
 
     android:layout_alignParentEnd="true" 
 
     android:id="@+id/btnok" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:layout_alignParentBottom="true" 
 
     android:layout_marginRight="5dp" 
 
     android:layout_marginEnd="5dp" 
 
     android:layout_marginTop="5dp" 
 
     android:text=" OK " /> 
 

 
</RelativeLayout>

和我的风格是像下面

<style name="Theme_Dialog" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="android:windowMinWidthMajor">100%</item> 
    <item name="android:windowMinWidthMinor">100%</item> 
</style> 

我想要在键盘上方进行对话,但它会变得完整。由于

回答

1

我刚才已经解决了它的表演对话前加入这一行

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

感谢