0

Ich entwerfe ein Layout für SignIn-Aktivität. Ich musste meinen Layoutbehältern feste Gewichte geben. Mein Problem ist, dass die Werkzeugleiste nach oben scrollt, wenn softInputKeyboard angezeigt wird.Restric Toolbar zum Scrollen bei der Anzeige von SoftInputKeyboard

Ich habe versucht android:windowSoftInputMode="adjustPan|stateVisible" aber keine der Optionen funktioniert für mich.

Auch das Setzen des Root-Layouts auf android:fitsSystemWindows="true" hat nicht geholfen.

Diese enter image description here

desceibes mein Problem.

und XML Layout:

<?xml version="1.0" encoding="utf-8"?> 
<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:fitsSystemWindows="true" 
    tools:context="tpltrakker.tplmap.ActivitySignIn"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_sign_in" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/app_color_greenish" 
      android:minHeight="?attr/actionBarSize" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    </android.support.design.widget.AppBarLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/appbar" 
     android:layout_marginLeft="@dimen/activity_horizontal_margin" 
     android:layout_marginRight="@dimen/activity_horizontal_margin" 
     android:orientation="vertical" 
     android:weightSum="100"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="45" 
      android:orientation="vertical" 
      android:weightSum="100"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_gravity="center" 
       android:layout_marginBottom="10dp" 
       android:layout_marginTop="10dp" 
       android:layout_weight="35" 
       android:gravity="center" 
       android:text="@string/title_hello" 
       android:textColor="@color/app_color_greenish" 
       android:textSize="30sp" /> 


      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_marginLeft="5dp" 
       android:layout_weight="12" 
       android:text="@string/label_sign_in" 
       android:textAppearance="@style/TextAppearance.AppCompat.Medium" 
       android:textStyle="normal" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="28" 
       android:gravity="center_vertical" 
       android:weightSum="10"> 

       <Button 
        android:id="@+id/btn_google" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="4.5" 
        android:drawableLeft="@drawable/google" 
        android:text="@string/button_google" 
        android:textAllCaps="false" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:theme="@style/AppTheme.ButtonGoogle" /> 

       <View 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        android:layout_marginRight="5dp" 
        android:layout_weight="1" /> 

       <Button 
        android:id="@+id/btn_fb" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="4.5" 
        android:drawableLeft="@drawable/facebook" 
        android:text="@string/button_facebook" 
        android:textAllCaps="false" 
        android:textAppearance="?android:attr/textAppearanceMedium" 

        android:theme="@style/AppTheme.ButtonFacebook" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_marginTop="5dp" 
       android:layout_weight="25" 
       android:orientation="horizontal" 
       android:weightSum="10"> 


       <View 
        android:layout_width="0dp" 
        android:layout_height="1dp" 
        android:layout_gravity="center" 
        android:layout_weight="4" 
        android:background="@color/divider_color" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="2" 
        android:gravity="center" 
        android:text="@string/label_or" 
        android:textColor="@color/app_color_greenish" 
        android:textSize="20sp" /> 

       <View 
        android:layout_width="0dp" 
        android:layout_height="1dp" 
        android:layout_gravity="center" 
        android:layout_weight="4" 
        android:background="@color/divider_color" /> 

      </LinearLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="10" 
      android:orientation="horizontal" 
      android:weightSum="10"> 

      <ImageView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:scaleType="fitStart" 
       android:src="@drawable/email" /> 

      <EditText 
       android:id="@+id/et_email" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_weight="9" 
       android:hint="@string/prompt_email" 
       android:inputType="textEmailAddress" 
       android:textAppearance="@style/TextAppearance.AppCompat.Medium" 
       android:textStyle="normal" /> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="10" 
      android:orientation="horizontal" 
      android:weightSum="10"> 

      <ImageView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:scaleType="fitStart" 
       android:src="@drawable/password" /> 

      <EditText 
       android:id="@+id/et_password" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_weight="9" 
       android:hint="@string/prompt_password" 
       android:inputType="textPassword" /> 

     </LinearLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="35"> 

      <Button 
       android:id="@+id/btn_login_new" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="5dp" 
       android:text="@string/action_sign_in" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:theme="@style/AppTheme.ButtonGreen" /> 

      <Button 
       android:id="@+id/btn_forget_pass" 
       style="@style/Widget.AppCompat.Button.Borderless" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/btn_login_new" 
       android:layout_marginTop="5dp" 
       android:text="@string/action_forget_pass" 
       android:textAllCaps="false" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/app_color_greenish" /> 

      <Button 
       android:id="@+id/btn_signup_new" 
       style="@style/Widget.AppCompat.Button.Borderless" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_marginBottom="5dp" 
       android:text="@string/action_sign_up" 
       android:textAllCaps="false" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/app_color_greenish" /> 

      <Button 
       android:id="@+id/btn_terms" 
       style="@style/Widget.AppCompat.Button.Borderless" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentRight="true" 
       android:layout_marginBottom="5dp" 
       android:text="@string/action_term" 
       android:textAllCaps="false" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/app_color_greenish" /> 


     </RelativeLayout> 

    </LinearLayout> 
</RelativeLayout> 

Dank!

Antwort

0

hinzufügen in AndroidManifest.xml für Ihre Aktivität:

android:windowSoftInputMode="adjustPan|adjustResize" 

Check this article on the Android developers' site aus, die beschreibt, wie die die Soft-Tastatur behandelt.

Das android:windowSoftInputMode Attribut kann verwendet werden, um festzulegen, was auf einer Basis pro-Aktivität geschieht: ob das Layout geändert wird oder ob es scrollt usw.

+0

making hinzufügen adjustPan | adjustResize macht das Layout gleich, wenn die Tastatur angezeigt wird. Keines der Layouts ist skalierbar oder skalierbar. Wie auch immer ich will nur meine Symbolleiste nicht schwenken, wenn die Tastatur angezeigt wird. –

0

Add folgende Zeile in Aktivität in AndroidManifest.xml registriert: -

android: windowSoftInputMode = "adjustResize"

+0

funktioniert nicht. t macht alle Layouts, um die Größe selbst zu ändern, während das Problem gleich bleibt. –

0

Ihre Symbolleiste xml ändern, und app:layout_collapseMode="pin"

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar_sign_in" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/app_color_greenish" 
    app:layout_collapseMode="pin" 
    android:minHeight="?attr/actionBarSize" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 
Verwandte Themen