0

CoordinatorLayout 내부에 AppBarLayout이 스크롤되어 있고 NestedScrollView, RecyclerView 및 다른보기가있는 첫 번째 레이아웃 안에 다른 레이아웃이 포함되어 있습니다.recycledview (내포 된 스크롤 뷰 내부)의 마지막 항목이 잘려서 가로 방향으로 뷰 페이지가 잘립니다.

나는이 레이아웃에서 직면하고있는 몇 가지 문제점이 있습니다.

  1. 활동 없음 부드러운 스크롤은 RecyclerView 내부에서 원활 을 스크롤합니다.

  2. RecyclerView의 마지막 항목이 맨 아래에서 잘립니다.

  3. 오리엔테이션을 변경하면 하단의 ViewPager가 완전히 자릅니다. 나는 더 이상 스크롤 할 수 없기 때문에.

    Item in the RecyclerView is cut

    Orientation cuts the ViewPager

    나는 또한 메인 레이아웃과 아래의 자식 레이아웃을 부착하고

. 나는 RecyclerView을로드하고 어디

activity_detail.xml movie_details.xml의 활동 "viewPager"내부

<?xml version="1.0" encoding="utf-8"?> 
<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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".DetailActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/iv_movie_backdrop" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:contentDescription="@string/str_movie_backdrop_image" 
       android:scaleType="fitXY" /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" /> 

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

    <include layout="@layout/movie_details" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/fab_margin" 
     app:layout_anchor="@id/app_bar" 
     app:layout_anchorGravity="bottom|end" 
     app:srcCompat="@drawable/ic_favorite_black_24dp" /> 

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

movie_details.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView 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:fillViewport="true" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.CardView 
      android:id="@+id/cv_poster_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="10dp" 
      android:elevation="@dimen/card_elevation" 
      app:cardCornerRadius="8dp" 
      app:cardUseCompatPadding="true" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintTop_toTopOf="parent"> 

      <ImageView 
       android:id="@+id/iv_movie_poster" 
       android:layout_width="150dp" 
       android:layout_height="200dp" 
       android:contentDescription="@string/str_movie_poster" 
       android:padding="@dimen/poster_padding" 
       android:scaleType="fitXY" 
       android:src="@drawable/not_found" /> 
     </android.support.v7.widget.CardView> 

     <TextView 
      android:id="@+id/tv_movie_title" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="70dp" 
      android:layout_marginStart="10dp" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceLarge" 
      android:textColor="@android:color/black" 
      android:textStyle="bold" 
      app:layout_constraintLeft_toRightOf="@+id/cv_poster_image" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="@+id/cv_poster_image" 
      tools:text="Spider Man and Iron Man" /> 


     <TextView 
      android:id="@+id/tv_release_date" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:drawablePadding="@dimen/poster_padding" 
      android:drawableStart="@drawable/ic_date_range_black_24dp" 
      android:gravity="start" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_movie_title" 
      app:layout_constraintTop_toBottomOf="@+id/tv_movie_title" 
      tools:text="March, 2017" /> 

     <TextView 
      android:id="@+id/tv_rating" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:drawablePadding="@dimen/poster_padding" 
      android:drawableStart="@drawable/ic_star_black_24dp" 
      android:gravity="start" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_release_date" 
      app:layout_constraintTop_toBottomOf="@+id/tv_release_date" 
      tools:text="7.1" /> 

     <TextView 
      android:id="@+id/tv_genre" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      android:textStyle="italic" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_rating" 
      app:layout_constraintTop_toBottomOf="@+id/tv_rating" 
      tools:text="Horror | Comedy | Drama" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/sliding_tabs" 
      style="@style/CategoryTab" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/cv_poster_image" 
      app:tabGravity="fill" /> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewPager" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/sliding_tabs" /> 

    </android.support.constraint.ConstraintLayout> 
</android.support.v4.widget.NestedScrollView> 

이다.

간단한 RecyclerView 아래에 어댑터 및 RecyclerView 코드가 추가되었습니다.

movie_trailers_fragment.xml 아래

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rv_movie_trailer_list" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

는 RecyclerView의 각 항목의 레이아웃입니다.

movie_trailer_item.xml 아래

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:elevation="@dimen/card_elevation" 
    card_view:cardCornerRadius="8dp" 
    card_view:cardUseCompatPadding="true"> 

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

     <ImageView 
      android:id="@+id/iv_trailer_poster" 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:contentDescription="@string/str_trailer_poster" 
      android:scaleType="fitXY" 
      android:src="@drawable/not_found" /> 

     <TextView 
      android:id="@+id/tv_trailer_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:padding="@dimen/detail_activity_text_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      tools:text="This Trailer Is Awesome" /> 

    </LinearLayout> 

</android.support.v7.widget.CardView> 

는 어댑터 클래스에 대한 코드입니다.

TrailerAdapter.java

public class MovieTrailersFragment extends Fragment { 
    public static final String MOVIE_TRAILERS_KEY = "trailer"; 

    public MovieTrailersFragment() { 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View view = inflater.inflate(R.layout.movie_trailers_fragment, container, false); 
     savedInstanceState = this.getArguments(); 
     List<MovieTrailer> movieTrailerList = (List<MovieTrailer>) savedInstanceState.getSerializable(MOVIE_TRAILERS_KEY); 
     RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_movie_trailer_list); 
     TrailerAdapter trailerAdapter = new TrailerAdapter(view.getContext()); 
     LinearLayoutManager linearLayoutManager = new LinearLayoutManager(view.getContext(),LinearLayoutManager.VERTICAL,false); 
     recyclerView.setLayoutManager(linearLayoutManager); 
     recyclerView.setNestedScrollingEnabled(true); 
     recyclerView.setHasFixedSize(true); 
     recyclerView.setItemAnimator(new DefaultItemAnimator()); 
     recyclerView.setAdapter(trailerAdapter); 
     trailerAdapter.prepareMovieTrailers(movieTrailerList); 
     return view; 
    } 

} 
+0

문제에 대한 해결책을 찾았습니까? 나는 같은 문제가 발생했습니다. –

+0

그래, 별도의 LinearLayout에서 TabLayout과 ViewPager를 분리해야만 제대로 작동했다. –

+0

RecylearView에 패딩을 추가하십시오. 그런 다음 마지막 항목이 표시됩니다. 호프가 문제를 해결할 수 있기를 바랍니다. –

답변

0

내가 별도의 LinearLayout에 TabLayout와 ViewPager을 분리했다 후 제대로했다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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:orientation="vertical"> 

    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.CardView 
      android:id="@+id/cv_poster_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="10dp" 
      android:elevation="@dimen/card_elevation" 
      app:cardCornerRadius="8dp" 
      app:cardUseCompatPadding="true" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintTop_toTopOf="parent"> 

      <ImageView 
       android:id="@+id/iv_movie_poster" 
       android:layout_width="150dp" 
       android:layout_height="200dp" 
       android:contentDescription="@string/str_movie_poster" 
       android:padding="@dimen/poster_padding" 
       android:scaleType="fitXY" 
       android:src="@drawable/not_found" /> 
     </android.support.v7.widget.CardView> 

     <TextView 
      android:id="@+id/tv_movie_title" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="60dp" 
      android:layout_marginStart="10dp" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceLarge" 
      android:textColor="@android:color/black" 
      android:textStyle="bold" 
      app:layout_constraintLeft_toRightOf="@+id/cv_poster_image" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="@+id/cv_poster_image" 
      tools:text="Spider Man and Iron Man" /> 


     <TextView 
      android:id="@+id/tv_release_date" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:drawablePadding="@dimen/poster_padding" 
      android:drawableStart="@drawable/ic_date_range_black_24dp" 
      android:gravity="start|center_vertical" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_movie_title" 
      app:layout_constraintTop_toBottomOf="@+id/tv_movie_title" 
      tools:text="March, 2017" /> 

     <TextView 
      android:id="@+id/tv_rating" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:drawablePadding="@dimen/poster_padding" 
      android:drawableStart="@drawable/ic_star_black_24dp" 
      android:gravity="start|center_vertical" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_release_date" 
      app:layout_constraintTop_toBottomOf="@+id/tv_release_date" 
      tools:text="7.1" /> 

     <TextView 
      android:id="@+id/tv_genre" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:padding="@dimen/poster_padding" 
      android:textAppearance="?android:textAppearanceSmall" 
      android:textColor="@android:color/black" 
      android:textStyle="italic" 
      app:layout_constraintLeft_toLeftOf="@+id/tv_rating" 
      app:layout_constraintTop_toBottomOf="@+id/tv_rating" 
      tools:text="Horror | Comedy | Drama" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab_tab_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="@dimen/fab_margin" 
      android:layout_marginRight="10dp" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="parent" 
      app:layout_constraintVertical_bias="0.0" 
      app:srcCompat="@drawable/ic_favorite_border_black_24dp" /> 

    </android.support.constraint.ConstraintLayout> 

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

     <android.support.design.widget.TabLayout 
      android:id="@+id/sliding_tabs" 
      style="@style/CategoryTab" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="10dp" 
      app:tabGravity="fill" /> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewPager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="10dp" /> 

    </LinearLayout> 

</LinearLayout> 

업데이트 위의 레이아웃이 레이아웃이 NestedScrollView를 포함하고 전용 인 FrameLayout이 내부로 보여되도록 내가 조각을 사용하고

: 아래

는 참조 용으로 수정 된 레이아웃입니다 Tablet 대형 스크린 장치의 경우에 사용됩니다.

대형 스크린 위의 조각에 대한 용기 :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <FrameLayout 
     android:id="@+id/detail_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</android.support.v4.widget.NestedScrollView> 
+0

하지만 NestedScrollView는 어디에 있습니까? 더 이상 사용하지 않습니까? –

+0

타블렛 레이아웃을 위해 조각을 사용하고 있었기 때문에 폰 레이아웃에만 NestedScrollView가 필요하지 않았습니다. –

0

나는 탐색 모음 앱 레이아웃을 겹쳐 있기 때문에 당신은 문제가 있다면 생각합니다. 당신은 네비게이션 바를 설치하거나 메인 테마 또는 활동 스타일을 던질 필요가 있습니다

+0

선형 레이아웃에서 뷰 페이지 및 tablayout을 분리하면 더 자세히 설명 할 수 있습니까? windowTranslucentNavigation 안드로이드 : fitSystemWindows 3 내가 스크롤 뷰 응용 프로그램 창에 대한 안드로이드를 검색하려고 탐색 표시 줄 아래에 있기 때문에 중복 문제는 스타일에 따라 2. 내부 아니라 재활용 작업을 알고 –

+0

1. 시도는 분명있는 ScrollView를 사용합니다. 아직 알지 못합니다 – user8064960

+0

문제는 하단 탐색 막대가없는 휴대 전화에서 실행해도 메모 5가 사용되었습니다. 그리고 scrollView를 사용하면 스크롤하는 앱바 효과를 얻지 못합니다. 내가 알기로 NestedScrollView는 뷰어 내부에서 리사이클 러 뷰를 사용하는 경우 화면 크기를 측정 할 수 없다. 그래서 선형 레이아웃을 추가하고 뷰 페이지를 분리했습니다. 내가 아래에서 대답 한 것처럼. –