Google의 자료 디자인 라이브러리에서 collapsingToolBar로 작업하기 위해 Android 개발을 처음 사용하고 있습니다. 나는이 전체 축소 도구 모음에 익숙하지 않지만 몇 가지 온라인 자습서를 따랐고 조언을 염두에두고 필요에 따라 XML을 만들었습니다. 5 개의 프래그먼트가 포함 된 viewPager의 주요 액티비티를 가지고 있습니다. 이제 사용자가 액티비티를 스크롤하고 액티비티의 나머지 부분이 축소 된 툴바 일 때 viewPager가 전체 화면을 차지해야합니다.Android - 자료 디자인 라이브러리 : collapsingToolBar 레이아웃 사용 방법
나머지 활동에는 평가 표시 줄과 일부 TextView가 포함 된 두 개의 imageView가 있습니다. 나는 이것들 모두가 붕괴 된 툴바 레이아웃과 호환이되는지 확신 할 수 없으므로 노력하고있다.
This 내가 말하고자했던 것입니다. 코디네이터 레이아웃 및 툴바 축소를 구현하기 전의 스크린 샷입니다.
Here은 앱에서 원하는 출력 유형입니다. 이 예제는 뷰 페이지에서 탭이 적지 만 기본적인 축소 도구 모음 레이아웃 구현은 동일합니다. 다음과 같이 앱의 playstore 행이 있습니다. play.google.com/store/apps/details?id=com.kkings.cinematics
여기 내 활동의 xml은 현재 활동입니다 (접히는 중 toolar) :
i.stack.imgur.com/hPruf.png 내가 어떤 변경하지 않은
:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/tvDescAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompact.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/tvDescCollapsingToolBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="@color/chocolateBrown"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:id="@+id/tvDescTabLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:paddingBottom="8dp">
<ImageView
android:id="@+id/tvBackgroundImage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true" />
<ImageView
android:id="@+id/tvImageMain"
android:layout_width="120dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="100dp"
android:foregroundGravity="left" />
<TextView
android:id="@+id/tvDescHeading"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tvBackgroundImage"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_toRightOf="@id/tvImageMain"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textStyle="bold|italic" />
<RatingBar
android:id="@+id/tvDescRating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/tvBackgroundImage"
android:layout_marginRight="8dp"
android:layout_marginTop="30dp"
android:gravity="center_vertical"
android:numStars="5"
android:stepSize="0.5"
android:visibility="visible" />
<TextView
android:id="@+id/tvDescIdTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvDescReleaseDate"
android:layout_below="@+id/tvDescRating"
android:layout_marginBottom="8dp"
android:layout_toLeftOf="@+id/tvDescId"
android:text="ID: "
android:textColor="#D2D2D2"
android:textSize="15sp"
android:textStyle="italic|bold" />
<TextView
android:id="@+id/tvDescId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/tvDescIdTag"
android:layout_below="@+id/tvDescRating"
android:layout_marginBottom="8dp"
android:layout_marginRight="16dp"
android:textColor="#D2D2D2"
android:textSize="15sp"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/tvDescReleaseDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvDescHeading"
android:layout_marginLeft="20dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@+id/tvImageMain"
android:textColor="#D6D6D6"
android:textSize="13sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvDescAppBarLayout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tvDescTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
app:tabMode="fixed"
app:tabTextAppearance="@style/Base.TextAppearance.AppCompat.Medium"
app:tabTextColor="@android:color/black" />
<android.support.v4.view.ViewPager
android:id="@+id/tvDescViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/white" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
이이 활동은 생산 결과의 유형입니다 자바에서. 크레딧이나 다른 클래스는 아무것도 표시 할 수 없습니다. 나는 이것이 recyclerView와 nestedScroll View 사이의 충돌로 인한 것 같아요.
어쨌든 모든 온라인 자습서에서 collapsingToolbarLayout 내부에 툴바를 사용했습니다. 그래서 같은 같은 일을 시도, 새로운 XML을 요 여기서 :
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/tvDescAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompact.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/tvDescCollapsingToolBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="@color/chocolateBrown"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparentColor"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:id="@+id/tvDescTabLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:paddingBottom="8dp">
<ImageView
android:id="@+id/tvBackgroundImage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true" />
<ImageView
android:id="@+id/tvImageMain"
android:layout_width="120dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="100dp"
android:foregroundGravity="left" />
<TextView
android:id="@+id/tvDescHeading"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tvBackgroundImage"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_toRightOf="@id/tvImageMain"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textStyle="bold|italic" />
<RatingBar
android:id="@+id/tvDescRating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/tvBackgroundImage"
android:layout_marginRight="8dp"
android:layout_marginTop="30dp"
android:gravity="center_vertical"
android:numStars="5"
android:stepSize="0.5"
android:visibility="visible" />
<TextView
android:id="@+id/tvDescIdTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvDescReleaseDate"
android:layout_below="@+id/tvDescRating"
android:layout_marginBottom="8dp"
android:layout_toLeftOf="@+id/tvDescId"
android:text="ID: "
android:textColor="#D2D2D2"
android:textSize="15sp"
android:textStyle="italic|bold" />
<TextView
android:id="@+id/tvDescId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/tvDescIdTag"
android:layout_below="@+id/tvDescRating"
android:layout_marginBottom="8dp"
android:layout_marginRight="16dp"
android:textColor="#D2D2D2"
android:textSize="15sp"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/tvDescReleaseDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvDescHeading"
android:layout_marginLeft="20dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@+id/tvImageMain"
android:textColor="#D6D6D6"
android:textSize="13sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvDescAppBarLayout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tvDescTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
app:tabMode="fixed"
app:tabTextAppearance="@style/Base.TextAppearance.AppCompat.Medium"
app:tabTextColor="@android:color/black" />
<android.support.v4.view.ViewPager
android:id="@+id/tvDescViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/white" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
이 도구 모음은 모든 이상한 만들고,이이 모습입니다 :
i.stack.imgur.com/PfqP9. png
또한 logcat에는 오류가 표시되지 않습니다.
나는 어디서 잘못 될지 알 수 없습니다. StackOverFlow에 대한 다른 비슷한 질문을 모두 확인했지만, 지금까지 해결 된 해결책은 없습니다. 여기
내가 튜토리얼 언급하고있다 :
www.youtube.com/watch?v=ssh09JbQ3nc
을 내가 잘못 여기서 뭐하는 거지?