Reputation: 1632
I am trying to use custom dialogue in one of my android application for edit text. I want show dialogue above the keyboard. I am getting half dialogue hidden below keyboard. I am unable to find solution for it. Let me know if someone expert here can help for solve this puzzle.
My java code for dialogue is like below
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);
and XML is like below
<?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>
and my style is like below
<style name="Theme_Dialog" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
I want dialogue above keyboard, but its getting full height. Thanks
Upvotes: 1
Views: 48
Reputation: 1632
I have just solved it by add this line before show dialogue
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Thanks
Upvotes: 1