2016-07-16 8 views
1

Ich habe ein ScrollView-Layout mit ViewPager und horizontalen RecyclerViews im Inneren, mein Problem ist, dass wenn ich die Tastatur ausblenden, die Seite ein wenig nach unten scrollen. Ich habe versucht, windowSoftInputMode zu adjustNothing zu ändern und es behebt das Problem, aber dann versteckt die Tastatur die SearchView-Vorschläge.Tastatur im Scrollview ausblenden Scrollen der Seite

Aus irgendeinem Grund passiert es nur, wenn die Seite eine bestimmte Länge erreicht, weil es nicht passiert, wenn ich zum Beispiel einen RecyclerView oder den ViewPager entferne.

Ich habe zwei Problemumgehungen für dieses Problem gefunden, eins ist die Sichtbarkeit der Layouts zu ändern, wenn Tastatur Popup und zurück zu sichtbar, wenn es ausgeblendet wird, und zweitens Tastatur mit SearchView ausblenden, wenn der Abfragetext den Fokus verliert , aber ich möchte wirklich eine richtige Lösung für dieses Problem finden.

Unten ist ein Video des Themas und der Code meines Layouts:

https://www.youtube.com/watch?v=hyexsQz8ja0

<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:scrollbars="none"> 

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

    <RelativeLayout 
     android:id="@+id/fragment_courses_relativeLayout_viewPager" 
     android:layout_height="200dp" 
     android:layout_width="match_parent"> 

     <ViewPager 
      android:id="@+id/main_catalog_view_pager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentTop="true" /> 

     <InkPageIndicator 
      android:id="@+id/main_catalog_indicator" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="10dp" 
      android:visibility="gone"/> 
    </RelativeLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/fragment_courses_software_see_all" 
     android:background="?attr/selectableItemBackground" 
     android:visibility="gone" 
     android:clickable="true" 
     android:minHeight="48.0dip"> 
     <FrameLayout 
      android:layout_gravity="center_vertical" 
      android:orientation="horizontal" 
      android:layout_width="0.0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/course_type_software" 
       android:textSize="20.0sp" 
       android:textColor="?android:textColorPrimary" 
       android:layout_marginStart="16dp" /> 
     </FrameLayout> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/see_all" 
      android:textColor="@color/colorAccent" 
      android:textAppearance="@style/TextAppearance.Button" 
      android:layout_gravity="center_vertical" 
      android:layout_marginEnd="@dimen/activity_horizontal_margin" 
      android:layout_marginStart="@dimen/activity_horizontal_margin" /> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fragment_courses_software_recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:paddingTop="4dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/fragment_courses_cyber_see_all" 
     android:background="?attr/selectableItemBackground" 
     android:visibility="gone" 
     android:clickable="true" 
     android:minHeight="48.0dip"> 
     <FrameLayout 
      android:layout_gravity="center_vertical" 
      android:orientation="horizontal" 
      android:layout_width="0.0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/course_type_cyber" 
       android:textSize="20.0sp" 
       android:textColor="?android:textColorPrimary" 
       android:layout_marginStart="16dp" /> 
     </FrameLayout> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/see_all" 
      android:textColor="@color/colorAccent" 
      android:textAppearance="@style/TextAppearance.Button" 
      android:layout_gravity="center_vertical" 
      android:layout_marginEnd="@dimen/activity_horizontal_margin" 
      android:layout_marginStart="@dimen/activity_horizontal_margin" /> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fragment_courses_cyber_recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:paddingTop="4dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/fragment_courses_it_see_all" 
     android:background="?attr/selectableItemBackground" 
     android:visibility="gone" 
     android:clickable="true" 
     android:minHeight="48.0dip"> 
     <FrameLayout 
      android:layout_gravity="center_vertical" 
      android:orientation="horizontal" 
      android:layout_width="0.0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/course_type_it" 
       android:textSize="20.0sp" 
       android:textColor="?android:textColorPrimary" 
       android:layout_marginStart="16dp" /> 
     </FrameLayout> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/see_all" 
      android:textColor="@color/colorAccent" 
      android:textAppearance="@style/TextAppearance.Button" 
      android:layout_gravity="center_vertical" 
      android:layout_marginEnd="@dimen/activity_horizontal_margin" 
      android:layout_marginStart="@dimen/activity_horizontal_margin" /> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fragment_courses_it_recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:paddingTop="4dp"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/fragment_courses_tools_see_all" 
     android:background="?attr/selectableItemBackground" 
     android:visibility="gone" 
     android:clickable="true" 
     android:minHeight="48.0dip"> 
     <FrameLayout 
      android:layout_gravity="center_vertical" 
      android:orientation="horizontal" 
      android:layout_width="0.0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/course_type_tools" 
       android:textSize="20.0sp" 
       android:textColor="?android:textColorPrimary" 
       android:layout_marginStart="16dp" /> 
     </FrameLayout> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/see_all" 
      android:textColor="@color/colorAccent" 
      android:textAppearance="@style/TextAppearance.Button" 
      android:layout_gravity="center_vertical" 
      android:layout_marginEnd="@dimen/activity_horizontal_margin" 
      android:layout_marginStart="@dimen/activity_horizontal_margin" /> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fragment_courses_tools_recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:paddingTop="4dp"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/fragment_courses_system_see_all" 
     android:background="?attr/selectableItemBackground" 
     android:visibility="gone" 
     android:clickable="true" 
     android:minHeight="48.0dip"> 
     <FrameLayout 
      android:layout_gravity="center_vertical" 
      android:orientation="horizontal" 
      android:layout_width="0.0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/course_type_system" 
       android:textSize="20.0sp" 
       android:textColor="?android:textColorPrimary" 
       android:layout_marginStart="16dp" /> 
     </FrameLayout> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/see_all" 
      android:textColor="@color/colorAccent" 
      android:textAppearance="@style/TextAppearance.Button" 
      android:layout_gravity="center_vertical" 
      android:layout_marginEnd="@dimen/activity_horizontal_margin" 
      android:layout_marginStart="@dimen/activity_horizontal_margin" /> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fragment_courses_system_recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:paddingTop="4dp"/> 

</LinearLayout> 

Antwort

1

I, indem folgendes Attribut auf die oberste Ansicht, das Problem zu beheben verwaltet der ScrollView, die in meinem Fall LinearLayout war:

Es stellte sich heraus, dass dieses Problem bei den RecyclerViews in der ScrollView-Datei aufgetreten ist und dass Google hier Issue 81854

gemeldet wurde
Verwandte Themen