0

Ich habe eine mainActivity hat 2 Fragments.Die Symbolleiste bewegt sich nach oben, wenn die Tastatur erscheint

Die mainActivity hat AppBar enthält eine Toolbar.

Einer von diesen Fragments hat 2 EditTexts.

image 1

wenn ich auf einer dieser EditText die Tastatur erscheint

image 2

aber, wie Sie die Toolbar (mit 2 Bildern drauf) verschwindet sehen.

auch nach unten bewegen ich die Tastatur es immer noch wie dieser

image 3

Ich versuche

android:windowSoftInputMode="adjustPan" 

meiner MainActivity in Manifest hinzufügen, aber es funktioniert immer noch nicht.

und ich versuche

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

zum onCreateView des Fragments hinzuzufügen, aber es funktioniert immer noch nicht.

Bitte, jede Hilfe, um die App-Leiste erscheint erscheint auch die Tastatur erscheint.

Es tut mir leid für mein schlechtes Englisch.

activity_main xml:

<android.support.design.widget.CoordinatorLayout 
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:id="@+id/main_content" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.example.lenovo.myapplication.MainActivity"> 

<android.support.v4.view.ViewPager 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="0dp" 
    android:layout_height="0dp" /> 

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

android:background="@android:drawable/screen_background_light_transparent" 
    android:gravity="top"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="185dp" 
     android:background="@drawable/pic" 
     android:gravity="top" 
     android:weightSum="1" 
     app:layout_scrollFlags="scroll|enterAlways"> 

     <ImageView 
      android:id="@+id/btn_exit" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_gravity="right" 
      android:layout_weight="0.29" 
      android:background="@drawable/exit" /> 

     <ImageView 
      android:layout_width="60dp" 
      android:layout_height="59dp" 
      android:layout_alignParentLeft="true" 
      android:layout_gravity="top|left" 
      android:layout_weight="0.38" 
      android:background="@drawable/logo" /> 
    </android.support.v7.widget.Toolbar> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" /> 
    </android.support.design.widget.AppBarLayout> 
</android.support.design.widget.CoordinatorLayout> 

mon_compte Fragment xml:

<android.support.constraint.ConstraintLayout 
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="wrap_content" 
android:layout_height="wrap_content" 

tools:context="com.example.lenovo.myapplication. 
MainActivity$PlaceholderFragment"> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="368dp" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     tools:layout_editor_absoluteX="8dp" 
     tools:layout_editor_absoluteY="8dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      tools:layout_editor_absoluteX="8dp" 
      tools:layout_editor_absoluteY="8dp"> 

      <EditText 
       android:id="@+id/txt_email" 
       android:layout_width="275dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:drawableLeft="@drawable/ic_email" 
       android:ems="10" 
       android:hint=" Votre E-mail" 
       android:inputType="textPersonName" 
       android:visibility="visible" /> 

      <EditText 
       android:id="@+id/txt_mdp" 
       android:layout_width="275dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:drawableLeft="@drawable/ic_lock" 
       android:ems="10" 
       android:hint=" Mot de passe" 
       android:inputType="textPassword" 
       android:password="true" 
       android:visibility="visible" /> 

      <Button 
       android:id="@+id/btn_enter" 
       android:layout_width="275dp" 
       android:layout_height="25dp" 
       android:layout_gravity="center_horizontal" 
       android:layout_marginTop="5dp" 
       android:background="@drawable/conexbtn" 
       android:text="Connexion" 
       android:textAllCaps="false" 
       android:textColor="@android:color/background_light" 
       android:visibility="visible" /> 

      <com.facebook.login.widget.LoginButton 
       android:id="@+id/btn_face" 
       android:layout_width="275dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_marginTop="10dp" 
       android:background="@drawable/facebtn" 
       android:text="Se connecter avec Facebook" 
       android:textAllCaps="false" 
       android:textColor="@android:color/background_light" 
       android:visibility="visible" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="5dp" 
       android:orientation="horizontal" 
       tools:layout_editor_absoluteX="17dp" 
       tools:layout_editor_absoluteY="258dp"> 

       <Button 
        android:id="@+id/btn_mdpo" 
        style="?android:attr/borderlessButtonStyle" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.18" 
        android:backgroundTint="@android:color/transparent" 
        android:onClick="btn_mdpo" 
        android:paddingLeft="50dp" 
        android:text="Mot de passe oublié?" 
        android:textAllCaps="false" 
        android:textColor="#bfbfbf" 
        android:textSize="13sp" /> 

       <Button 
        android:id="@+id/btn_i" 
        style="?android:attr/borderlessButtonStyle" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.18" 
        android:backgroundTint="@android:color/transparent" 
        android:onClick="btn_i" 
        android:paddingRight="50dp" 
        android:text="Nouveau sur wach?" 
        android:textAllCaps="false" 
        android:textColor="#bfbfbf" 
        android:textSize="13sp" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:orientation="vertical"> 

       <Button 
        android:id="@+id/btn_sht" 
        style="?android:attr/borderlessButtonStyle" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom|right" 
        android:layout_weight="0.18" 
        android:backgroundTint="@android:color/transparent" 
        android:onClick="btn_sht" 
        android:paddingRight="50dp" 
        android:text="by Soft High Tech" 
        android:textAllCaps="false" 
        android:textColor="#000000" 
        android:textSize="14sp" /> 
      </LinearLayout> 
     </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</android.support.constraint.ConstraintLayout> 

Antwort

0

auf Ihrem Manifest Add

android:windowSoftInputMode="adjustResize" 

wenn es auf Ihren Eltern Layout funktioniert nicht addiere

android:fitsSystemWindows="true" 
+0

Boukharist. es funktioniert immer noch nicht – Hamiprogrammer

+0

remove getActivity(). getWindow(). setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); – Boukharist

+0

ich entferne es. es funktioniert immer noch nicht! – Hamiprogrammer

0

Try RelativeLayout als Top-Eltern zu verwenden (Sie müssen wahrscheinlich einige Teile Refactoring so das Layout die gleiche wie vorher aussehen. Dafür können Sie android:layout_below und android:layout_above verwenden. Klicken Sie auf here für weitere Informationen ...) und setzen Sie android:fitsSystemWindows="true" darin. Fügen Sie auch android:layout_alignParentTop="true" in der Symbolleiste hinzu.

+0

wenn ich CoordinatorLayout von RelativeLayout in activity_main XML die Symbolleiste bleiben ..aber die Bestandteile des Fragments bewegen sich nach oben! https://imgur.com/a/cOsjT – Hamiprogrammer

+0

Ja, das ist normal. Sie müssen android: layout_below und android: layout_oben einfügen, um die Komponenten nach Ihren Wünschen auszurichten. Ich werde einen Link in die Antwort einfügen, den Sie lesen können. – gbruscatto

Verwandte Themen