2012-07-10 6 views
17

Lassen Sie sagen, ich habe folgendes Layout:Layout des Bildschirms bewegt sich nach oben, wenn Tastatur angezeigt wird

http://i47.tinypic.com/2vchnih.png

, wenn ich am Ende auf dem Bearbeiten von Text klicken bekomme ich diese:

http://i45.tinypic.com/352lym9.png

Wie Sie sehen können, geht das Bild von oben nach oben und das gesamte Layout bewegt sich. Das ist mein xml für dieses Layout:

<?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="fill_parent" 
    android:background="#FFFFFF" > 

    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="fill_parent" 
     android:layout_height="75dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true"   
     android:isScrollContainer="true" 
     android:background="@drawable/header" > 
    </LinearLayout> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/scrollauthentication" 
     android:layout_below="@+id/header" 
     android:background="#FFFFFF" 
     android:fillViewport="true" > 

     <RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#FFFFFF" 
      android:id="@+id/authenticationrelativelayout"> 

      <TextView 
       android:id="@+id/login" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/header" 
       android:layout_marginLeft="30dp" 
       android:layout_marginTop="20dp" 
       android:text="login" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/lighter_orange" 
       android:textSize="28dp" /> 

      <TextView 
       android:id="@+id/usernameTextView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/login" 
       android:layout_below="@+id/login" 
       android:layout_marginTop="16dp" 
       android:text="username" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/dark_gray" /> 

      <EditText 
       android:id="@+id/user" 
       android:layout_width="260dp" 
       android:layout_height="42dp" 
       android:layout_alignLeft="@+id/usernameTextView" 
       android:layout_below="@+id/usernameTextView" 
       android:background="@drawable/edittext_selector" 
       android:imeOptions="actionDone" 
       android:lines="1" 
       android:paddingLeft="10dp" /> 

      <TextView 
       android:id="@+id/passwordTextView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/user" 
       android:layout_below="@+id/user" 
       android:text="password" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/dark_gray" /> 

      <EditText 
       android:id="@+id/password" 
       android:layout_width="260dp" 
       android:layout_height="42dp" 
       android:layout_alignLeft="@+id/passwordTextView" 
       android:layout_below="@+id/passwordTextView" 
       android:background="@drawable/edittext_selector" 
       android:imeOptions="actionDone" 
       android:inputType="textPassword" 
       android:lines="1" 
       android:paddingLeft="10dp" > 

       <requestFocus /> 
      </EditText> 

      <CheckBox 
       android:id="@+id/remembercheckBox" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/password" 
       android:layout_below="@+id/password" 
       android:layout_marginTop="37dp" 
       android:button="@drawable/checkbox_selector" 
       android:focusable="true" /> 

      <TextView 
       android:id="@+id/rememberText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignBaseline="@+id/remembercheckBox" 
       android:layout_alignBottom="@+id/remembercheckBox" 
       android:layout_toRightOf="@+id/remembercheckBox" 
       android:text="Remember me" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/dark_gray" /> 
     </RelativeLayout> 
    </ScrollView> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="30dp" 
     android:layout_below="@+id/scrollauthentication" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/loginButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@color/button_selected" 
      android:text="log in" 
      android:textColor="@drawable/textblack_selected" 
      android:textStyle="bold" > 
     </Button> 

     <Button 
      android:id="@+id/forgotten" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:background="@color/button_selected" 
      android:text="forgotten password" 
      android:textColor="@drawable/textblack_selected" 
      android:textStyle="bold" /> 
    </LinearLayout> 

</RelativeLayout> 

Und ich habe auch diese in Manifest-Datei für diese Tätigkeit eingestellt:

android:windowSoftInputMode="adjustPan" 

So gibt es eine Möglichkeit, mein Layout zu stoppen bewegen, wenn die Tastatur wird angezeigt? Vielen Dank !!!!

+0

prüfen Sie diesen Link: http://stackoverflow.com/questions/9989130/page-scroll-when-soft-keyboard-poped-up –

+0

Ich denke, dieser Link wird Ihnen helfen. [Link] [1] [1]: http://stackoverflow.com/questions/5516216/how-to-avoid-soft-keyboard-pushing-up-my-layout Dank ... – user4232

+0

@YogeshSomani gibt es nichts drin habe ich nicht ausprobiert. und es funktioniert nicht – adrian

Antwort

10

Nun, ich habe keine "windowSoftInputMode" im Manifest meiner App erwähnt und es läuft gut. Der Bildschirm bewegt sich nicht nach oben, wenn die Tastatur geöffnet wird. Versuchen Sie diesen Ansatz - entfernen Sie einfach den Parameter "windowSoftInputMode" aus Ihrem Manifest.

26

Try

android:windowSoftInputMode="adjustPan|adjustResize" 

für die Aktivität verwendet wird.

+0

Ich habe es versucht.Es macht keinen Unterschied – adrian

+0

Können Sie bitte Ihren Manifest-Dateicode anzeigen? – SALMAN

+5

versuchen Sie dies für Ihre ScrollView Android: isScrollContainer = "false" das kann Ihnen helfen. – SALMAN

1

Try this:

android:windowSoftInputMode="adjustNothing" 
+1

Während dieses Code-Snippet willkommen ist und vielleicht etwas Hilfe bietet, wäre es [stark verbessert, wenn es eine Erklärung enthielt] (// meta.stackexchange.com/q/114762) von * wie * und * warum * das löst das Problem Problem. Denken Sie daran, dass Sie die Frage für Leser in der Zukunft beantworten, nicht nur die Person, die jetzt fragt! Bitte [bearbeiten] Sie Ihre Antwort, um eine Erläuterung hinzuzufügen und geben Sie an, welche Einschränkungen und Annahmen gelten. –

2

Mein EditText als auch nach oben bewegt gehalten.

Das Hinzufügen von Gravitation zum Bearbeiten von Text scheint das Problem zu lösen. Die Tastatur hat meinen EditText hochgedrückt, also habe ich am Ende des Editiertextes in der XML Gravitation hinzugefügt.

android:gravity=bottom 
0

Ich hatte bereits eine windowsoftInputMode die Tastatur von Öffnen zu verhindern, so fügen Sie einfach den Kommentar Code

android: windowSoftInputMode = "stateHidden | adjustPan | adjustResize"

Verwandte Themen