26

Wenn ich versuche, etwas in einem EditText zu schreiben, die am unteren Rand des Bildschirms Soft-Tastatur ist versteckt editText.how kann ich dieses Problem beheben? Unten ist mein XML-Code. Ich benutze diesen Bildschirm in Fragment.Android Tastatur versteckt EditText

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 


     <LinearLayout 
      android:id="@+id/linearLayoutTopDetails" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayoutTop" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="6dp" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/list_design1" 
       android:orientation="vertical" > 

       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="80dp" 
        android:layout_weight="100" 
        android:orientation="horizontal" > 

        <ImageView 
         android:id="@+id/ImageViewProfImagePostDetail" 
         android:layout_width="0dp" 
         android:layout_height="fill_parent" 
         android:layout_marginTop="2dp" 
         android:layout_weight="24.84" 
         android:paddingLeft="5dp" 
         android:paddingRight="5dp" 
         android:paddingTop="5dp" /> 

        <LinearLayout 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="60" 
         android:orientation="vertical" > 

         <TextView 
          android:id="@+id/textViewNamePostDetail" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="Robin" 
          android:textSize="17sp" /> 

         <TextView 
          android:id="@+id/textViewLocationPostDetail" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="1dp" 
          android:drawableLeft="@drawable/location" 
          android:text="beijing, China" /> 

         <TextView 
          android:id="@+id/textViewTimeAgoPostDetail" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text=" 18min ago" /> 
        </LinearLayout> 

        <LinearLayout 
         android:layout_width="0dp" 
         android:layout_height="fill_parent" 
         android:layout_weight="15" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/textViewReportAbusePostDetail" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:background="@drawable/flag" 
          android:paddingLeft="5dp" /> 

         <TextView 
          android:id="@+id/textViewDeletePostDetail" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginLeft="15dp" 
          android:background="@drawable/delete" 
          android:visibility="gone" /> 
        </LinearLayout> 
       </LinearLayout> 

       <TextView 
        android:id="@+id/textViewDescriptionPostDetail" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="20dp" 
        android:layout_marginTop="2dp" 
        android:singleLine="false" 
        android:text="Description or caption of the post" 
        android:textSize="17sp" /> 
      </LinearLayout> 

      <ImageView 
       android:id="@+id/feedPostedImagePostDetail" 
       android:layout_width="fill_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="5dp" 
       android:scaleType="fitCenter" 
       android:visibility="gone" /> 

      <LinearLayout 
       android:id="@+id/linearLayoutOptions" 
       android:layout_width="fill_parent" 
       android:layout_height="33dp" 
       android:layout_marginTop="2dp" 
       android:layout_weight="100" 
       android:background="@drawable/bar" 
       android:orientation="horizontal" > 

       <TextView 
        android:id="@+id/textViewShakePostDetail" 
        android:layout_width="0dp" 
        android:layout_height="fill_parent" 
        android:layout_marginLeft="15dp" 
        android:layout_weight="25" 
        android:drawableLeft="@drawable/like" 
        android:gravity="center" 
        android:singleLine="true" 
        android:text="Shake" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/textViewCommentPostDetail" 
        android:layout_width="0dp" 
        android:layout_height="fill_parent" 
        android:layout_weight="41" 
        android:drawableLeft="@drawable/comment" 
        android:gravity="center" 
        android:paddingLeft="20dp" 
        android:text="Comment" /> 

       <TextView 
        android:id="@+id/textViewSharePostDetail" 
        android:layout_width="0dp" 
        android:layout_height="fill_parent" 
        android:layout_weight="33" 
        android:drawableLeft="@drawable/share" 
        android:gravity="center" 
        android:paddingLeft="20dp" 
        android:text="Spread" /> 
      </LinearLayout> 
     </LinearLayout> 

     <ListView 
      android:id="@+id/listViewFeedsDetail1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayoutTopDetails" 
      android:layout_marginBottom="4dp" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="6dp" > 
     </ListView> 

     <LinearLayout 
      android:id="@+id/linearLayoutPostcomment" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/listViewFeedsDetail1" 
      android:background="#FFFFFF" 
      android:orientation="horizontal" 
      android:weightSum="100" > 

      <EditText 
       android:id="@+id/editTextComment" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="80" /> 

      <Button 
       android:id="@+id/buttonPostComment" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="20" 
       android:background="#F0F8FF" 
       android:text="Post" > 
      </Button> 
     </LinearLayout> 
    </RelativeLayout> 
</ScrollView> 

`

Ich habe versucht, durch Hinzufügen von Änderungen durch Code, um dieses Problem zu beheben, aber ohne Erfolg.

Unten ist das Bild vor und nach dem Einschalten der EditText klicken. enter image description here

enter image description here

+1

scrollview funktioniert nicht. –

+1

Fügen Sie diese Eigenschaften: android: windowSoftInputMode = "adjustPan | adjustResize" zu Ihrem Aktivitäts-Tag in AndroidManifest.xml –

+0

möglich Duplikat [Android Soft-Tastatur umfasst EditText Feld] (http://stackoverflow.com/questions/3295672/android-soft -keyboard-covers-edittext-field) – Lamorak

Antwort

30

In Ihrem Manifest diese in deine perticular Aktivität:

android:windowSoftInputMode="adjustPan" 
+2

Ich habe das versucht, aber keinen Erfolg. android: windowSoftInputMode = "adjustPan | adjustResize" Dieser Code befindet sich immer noch in meinem manifest.but, versteckt aber editText. –

+0

danke @ Kishan. Arbeitszauber für mich. –

14

Dafür Sie erklärt in Ihrer Tätigkeit haben manifeast

  <activity 
      android:name=".activityname" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="adjustPan|adjustResize" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
+0

Dies ist mein Manifest-Code für Aktivitäten. Dies versteckt editText immer noch. –

+1

Es ist Fragment keine Aktivität. Wo soll ich das tun? Ich habe diesen Code bereits in Aktivität eingefügt, in der das Fragment platziert wird. –

+4

@RobinRoyal kann ich bin zu spät, aber (meine für andere nützlich sein) verwenden Sie entweder adjustPan oder adjustResize, nicht beide gleichzeitig –

2

Verwenden den Code unten, wo:

InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
       ipmm.hideSoftInputFromWindow(url.getWindowToken(), 0); 

wo url in meinem Code ist:

url = (EditText) findViewById(R.id.eT_webbrowser); 

oder Versuchen Sie folgendes:

InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
        ipmm.hideSoftInputFromWindow(null, 0); 

Als weitere Option dies versuchen: Diese immer versteckt die Soft-Input-Modus, so dass Ihre EditText sichtbar ist

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
+0

@Robin Royal - Wenn es für Sie funktioniert, akzeptieren Sie es bitte als Antwort. –

+0

Scrolle nicht den editText nach oben. –

+0

Ich habe dich nicht verstanden. Aber haben Sie auch mit 'null' als Option versucht? –

1

Deklarieren Sie windowSoftInputMode = "adjustResize" in der Datei "manifest.xml"

<activity 
     android:name=".example" 
     android:theme="@style/AppTheme.NoActionBar" 
     android:windowSoftInputMode="adjustResize" /> 

scroll Blick auf die Dies scheint

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="16dp" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" 
     android:paddingTop="16dp" 
     android:fitsSystemWindows="true"> 

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true" 
     android:isScrollContainer="false"> 

    // add edittext here... 

</ScrollView> 
</RelativeLayout> 
2

Hier ist einfache Lösung für Android EditText Ausgabe von hinter SoftKeypad versteckt. Verwenden Sie den Code in der Datei AndroidManifest.xml des Projektmoduls.

<activity 
     android:name="com.example.MainActivity" 
     android:label="@string/activity_main" 
     android:windowSoftInputMode="adjustResize|stateHidden" /> 

Dieser Code für mich gearbeitet.
Innerhalb der Manifest-Datei in Aktivitäts-Tag hinzufügen, um dieses Attribut:

android:windowSoftInputMode="adjustResize|stateHidden" 

Es gibt mehr solche Werte für dieses Attribut (android:windowSoftInputMode), die als Empfehlungsliste kommen. Sie können mit ihnen auch überprüfen.

Verwandte Themen