2016-07-16 2 views
1

ViewPager와 수평 RecyclerViews가있는 ScrollView 레이아웃이 있습니다. 키보드를 숨기면 페이지가 조금 아래로 스크롤됩니다. 나는 windowSoftInputMode를 adjustNothing으로 변경하려고 시도했지만 문제가 해결되지만 키보드는 SearchView 제안을 숨 깁니다.키보드를 scrollview에 숨기기 페이지 스크롤

어떤 이유로 인해 페이지가 일정한 길이에 도달 할 때만 발생합니다. 예를 들어 하나의 RecyclerView 또는 ViewPager를 제거하면 발생하지 않기 때문입니다.

이 문제에 대한 두 가지 해결 방법을 발견했습니다. 하나는 키보드 팝업을 표시 할 때 사라지게 할 레이아웃의 가시성을 변경하는 것이고, 숨길 때 다시 표시하고 두 번째는 쿼리 텍스트가 포커스를 잃을 때 SearchView와 함께 키보드를 숨기는 것입니다. ,하지만 난 정말이 문제에 대한 적절한 수정을 찾고 싶다.

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> 

답변

1

내가 최상위 뷰에 다음 속성을 추가하여 문제를 해결하기 위해 관리 : 아래

이 문제의 비디오 및 내 레이아웃의 코드 내 경우 LinearLayout :

android:focusableInTouchMode="true" 

이 문제는 ScrollView 내부의 RecyclerViews와 관련되어 있으며 여기에 Google에보고되었습니다. Issue 81854

관련 문제