2017-03-22 2 views
2

edittext covered by keyboardAndroid BottomSheetDialog mit EditText von Tastatur bedeckt

Hier ist mein Dialog-Layout Inhalt. Wenn die Schaltfläche auf dem Bildschirm angeklickt wird, wird dieser Dialog angezeigt und von der Tastatur abgedeckt. Wie man dieses Problem löst?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
android:background="#FFFFFF" 
android:layout_width="400dp" 
android:layout_height="match_parent"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:text="textview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <EditText 
     android:layout_width="30dp" 
     android:layout_alignParentBottom="true" 
     android:layout_height="wrap_content" /> 
</RelativeLayout> 
</LinearLayout> 
+0

Sie öffnen Tastatur auf die Schaltfläche klicken oder EditText klicken ?? –

Antwort

0

Fügen Sie diese in Ihrer Klasse:

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 

Die obige Codezeile Ihr Layout drücken wird, um die EditText sichtbar zu machen, wenn es den Fokus hat & Tastatur zu sehen ist.

2
<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:background="#FFFFFF" 
    android:layout_width="400dp" 
    android:windowSoftInputMode="adjustPan|adjustResize" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <TextView 
      android:text="textview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <EditText 
      android:layout_width="30dp" 
      android:layout_alignParentBottom="true" 
      android:layout_height="wrap_content" /> 
    </RelativeLayout> 
    </LinearLayout> 
-1

versuchen, diese

public void show_Messgae() { 

    final Dialog mDialog = new Dialog(this); 
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    Window window = mDialog.getWindow(); 
    window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
    window.setGravity(Gravity.CENTER); 
    mDialog.getWindow().setBackgroundDrawable(
      new ColorDrawable(android.graphics.Color.WHITE)); 

    //diaog is the name of ur layout 
    mDialog.setContentView(R.layout.dialog); 

    mDialog.setCancelable(false); 

    EditText et_name=(EditText)mDialog.findViewById(R.id.et_name); 

    //to show keyboard 
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); 

    mDialog.show(); 



} 
Verwandte Themen