, когда я хочу реализовать YouTube как движение Пример с здесь Я получил некоторую ошибку.вот мои XML-коды.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:fitsSystemWindows="true"
android:layoutDirection="rtl"
tools:context=".presentation.activities.MainActivity">
<android.support.constraint.motion.MotionLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".presentation.activities.MainActivity">
<android.support.constraint.ConstraintLayout
android:id="@+id/top_image_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<com.dastangram.app.presentation.components.Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
<FrameLayout
android:id="@+id/place_holder"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toTopOf="@id/media_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/media_holder"
android:layout_width="match_parent"
android:layout_height="80dp"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
android:background="@drawable/rect_radius_lower"
android:visibility="visible" />
<android.support.design.widget.BottomNavigationView
android:layout_gravity="bottom"
android:theme="@style/BottomNavigation"
android:id="@+id/bottom_navigation"
android:background="@color/colorPrimary"
app:itemIconTint="@drawable/bottom_nav_colors"
app:itemTextColor="@drawable/bottom_nav_colors"
app:menu="@menu/mnu_bottom_navigation"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.motion.MotionLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorPrimary"
android:fitsSystemWindows="true"
app:headerLayout="@layout/drawer_layout">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
frag_main:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:background="@color/colorPrimary"
android:layoutDirection="rtl"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_margin="25dp"
android:padding="7dp"
android:imeOptions="flagNoExtractUi"
android:paddingStart="15dp"
android:textColor="@color/color_text_color"
android:background="@drawable/rect_radius"
android:textColorHint="@color/color_text_color"
android:hint="@string/str_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:layout_gravity="end"
android:layout_marginTop="33dp"
android:layout_marginEnd="33dp"
android:tint="@color/color_text_color"
android:src="@drawable/ic_search"
android:layout_width="24dp"
android:layout_height="24dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_main"
android:layout_marginTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_text_color"/>
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
frag_media_player.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
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/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#444"
app:layoutDescription="@xml/scene_24"
tools:ignore="contentDescription">
<android.support.constraint.ConstraintLayout
android:id="@+id/constrains_media"
android:layoutDirection="ltr"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img_media_cover"
android:src="@drawable/ic_close_black"
android:layout_gravity="center_horizontal"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.14999998"/>
<ImageView
android:src="@drawable/ic_fast_forward"
android:tint="@color/color_text_color"
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/img_fast_next"
app:layout_constraintStart_toEndOf="@+id/img_sec_forward"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.6"/>
<ImageView
android:src="@drawable/ic_forward_30_black"
android:tint="@color/color_text_color"
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/img_sec_forward"
app:layout_constraintStart_toEndOf="@+id/play_pause_view"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/img_fast_next"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.6"
app:layout_constraintBottom_toBottomOf="parent"/>
<com.ohoussein.playpause.PlayPauseView
android:id="@+id/play_pause_view"
android:clickable="true"
android:foreground="?android:selectableItemBackground"
app:fill_color="#e1e1e1"
app:pause_bg="@color/color_back_box"
app:play_bg="@color/color_text_color"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintStart_toEndOf="@+id/img_sec_back"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/img_sec_forward"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6"/>
<ImageView
android:src="@drawable/ic_replay_10_black"
android:tint="@color/color_text_color"
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/img_sec_back"
app:layout_constraintStart_toEndOf="@+id/img_fast_prev"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/play_pause_view"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.6"/>
<ImageView
android:src="@drawable/ic_fast_rewind"
android:tint="@color/color_text_color"
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/img_fast_prev"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/img_sec_back"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6"/>
<ImageView
android:layout_gravity="center"
android:tint="@color/color_text_color"
android:src="@drawable/ic_page"
android:layout_width="20dp"
android:layout_height="20dp"
android:id="@+id/img_media_desc"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.8"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"/>
<ProgressBar
android:id="@+id/pb_media"
android:layout_width="225dp"
android:layoutDirection="ltr"
android:layout_height="wrap_content"
style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"
android:layout_gravity="center"
android:progressTint="@color/color_text_color"
android:progressBackgroundTint="#4d34ff"
android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.85"/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.motion.MotionLayout>
scene_24.xml:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by motionlicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@id/end"
motion:constraintSetStart="@id/start"
motion:duration="1000"
motion:interpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/constrains_media"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragUp" />
<ConstraintSet android:id="@id/start">
<Constraint
android:id="@id/constrains_media"
android:layout_width="0dp"
android:layout_height="320dp"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent" />
<Constraint
android:id="@id/img_media_cover"
android:layout_width="0dp"
android:layout_height="0dp"
motion:layout_constraintTop_toTopOf="@id/constrains_media"
motion:layout_constraintBottom_toBottomOf="@id/constrains_media"
motion:layout_constraintStart_toStartOf="@id/constrains_media"
motion:layout_constraintEnd_toEndOf="@id/constrains_media"
/>
<Constraint
android:id="@id/img_media_desc"
android:layout_width="0dp"
android:layout_height="0dp"
motion:layout_constraintTop_toBottomOf="@id/constrains_media"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@id/img_fast_next"
android:layout_width="0dp"
android:layout_height="0dp"
motion:layout_constraintTop_toBottomOf="@id/constrains_media"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"/>
<Constraint android:id="@id/play_pause_view" >
<PropertySet motion:alpha="0" />
</Constraint>
<Constraint android:id="@id/img_fast_prev" >
<PropertySet motion:alpha="0" />
</Constraint>
<!--<Constraint
android:id="@id/bottom_nav"
android:layout_width="0dp"
android:layout_height="wrap_content"
motion:layout_constraintTop_toBottomOf="parent"
motion:layout_constraintLeft_toLeftOf="parent"
motion:layout_constraintRight_toRightOf="parent" />-->
</ConstraintSet>
<ConstraintSet android:id="@id/end">
<Constraint
android:id="@id/constrains_media"
android:layout_width="0dp"
android:layout_height="54dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"/>
<Constraint
android:id="@id/img_media_cover"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
motion:layout_constraintTop_toTopOf="@id/constrains_media"
motion:layout_constraintBottom_toBottomOf="@id/constrains_media"
motion:layout_constraintStart_toStartOf="@id/constrains_media"
motion:layout_constraintDimensionRatio="H,1:2.5"
/>
<Constraint
android:id="@id/img_media_desc"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
motion:layout_constraintTop_toBottomOf="@id/constrains_media"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@id/img_fast_next"
android:layout_width="0dp"
android:layout_height="0dp"
android:alpha="0"
motion:layout_constraintTop_toBottomOf="@id/constrains_media"
motion:layout_constraintBottom_toBottomOf="@id/constrains_media"
motion:layout_constraintEnd_toEndOf="@id/constrains_media"
motion:layout_constraintStart_toStartOf="@id/constrains_media"
/>
<Constraint android:id="@id/play_pause_view" >
<PropertySet motion:alpha="1" />
</Constraint>
<Constraint android:id="@id/img_fast_prev" >
<PropertySet motion:alpha="1" />
</Constraint>
<!--<Constraint-->
<!--android:id="@id/bottom_nav"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="?android:attr/windowBackground"-->
<!--motion:layout_constraintBottom_toBottomOf="parent"-->
<!--motion:layout_constraintLeft_toLeftOf="parent"-->
<!--motion:layout_constraintRight_toRightOf="parent" />-->
</ConstraintSet>
<KeyFrameSet>
<KeyPosition
motion:target="@id/img_media_cover"
motion:framePosition="90"
motion:percentX="0"
motion:curveFit="linear"
/>
<KeyPosition
motion:target="@id/constrains_media"
motion:framePosition="90"
motion:curveFit="linear"
/>
<KeyPosition
motion:target="@id/img_media_desc"
motion:framePosition="90"
motion:curveFit="linear"
/>
<KeyAttribute
android:alpha="0"
motion:framePosition="75"
motion:target="@id/img_fast_next" />
<KeyAttribute
android:alpha="0.10"
motion:framePosition="90"
motion:target="@id/img_fast_prev" />
<KeyAttribute
android:alpha="0.10"
motion:framePosition="90"
motion:target="@id/play_pause_view" />
</KeyFrameSet>
</Transition>
</MotionScene>
в activity_main.xml Я использую два frameLayout, чтобы показать два разных фрагмента.один для фрагмента_основного.xml, а другой для фрагмента_медиа.xml.Я хочу, чтобы "YouTube like motion Example" понравился, когда проводишь вверх, я вижу все части Media Player, а когда проводишь вниз, просто видишь img_cover и playPauseView и ProgressBar.Пожалуйста, помогите мне найти ошибку в моем коде ?!спасибо