Skip to content

Commit

Permalink
Add comments to XML files
Browse files Browse the repository at this point in the history
  • Loading branch information
objcode committed Aug 23, 2020
1 parent da7d2ad commit a303777
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.androidstudio.motionlayoutintegrations.databinding.ActivityCollapsingToolbarBinding
import com.google.android.material.appbar.AppBarLayout
import kotlinx.android.synthetic.main.activity_entrance.*

class CollapsingToolbar : AppCompatActivity() {

Expand Down Expand Up @@ -50,7 +49,7 @@ class CollapsingToolbar : AppCompatActivity() {
binding.motionLayout.minimumHeight = desiredToolbarHeight + insetTopHeight

// modify the end ConstraintSet to set a guideline at the top and bottom of inset
val endConstraintSet = binding.motionLayout.getConstraintSet(R.id.end)
val endConstraintSet = binding.motionLayout.getConstraintSet(R.id.collapsed)
// this guideline is the bottom of the inset area
endConstraintSet.setGuidelineEnd(R.id.inset, desiredToolbarHeight)
// this guideline is the top of the inset area (top of screen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<ImageView
android:id="@+id/scrolling_background"
android:layout_width="0dp"
android:layout_height="4478px"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/star_paralax"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="PxUsage" />
/>


<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">

<ConstraintSet android:id="@+id/Welcome" >
<!-- This animation uses a series of autoprogress between different ConstraintSet to build
keyframes of the animation.
As the animation plays, MotionLayout will display each ConstraintSet in turn.
Each ConstraintSet uses deriveConstraintsFrom the previous constraint set to only specify the
changes needed for the next KeyFrame.
-->
<ConstraintSet android:id="@+id/initial" >
<Constraint
android:id="@+id/scrolling_background"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="4478px"
android:layout_height="wrap_content"
android:alpha="0"
/>
</ConstraintSet>
Expand Down Expand Up @@ -172,8 +180,10 @@
android:layout_marginEnd="16dp"
/>
</ConstraintSet>
<!-- Each transition uses animateToEnd to combine a sequence of smaller animations into one
big entrance animation. -->
<Transition
motion:constraintSetStart="@+id/Welcome"
motion:constraintSetStart="@+id/initial"
motion:constraintSetEnd="@+id/empty"
motion:motionInterpolator="linear"
motion:autoTransition="animateToEnd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,42 @@
xmlns:android="http://schemas.android.com/apk/res/android">

<Transition
app:constraintSetEnd="@+id/end"
app:constraintSetStart="@id/start"
app:constraintSetEnd="@+id/collapsed"
app:constraintSetStart="@id/expanded"
>
<KeyFrameSet >
<!-- Hold title in place -->
<KeyPosition
app:motionTarget="@+id/title"
app:framePosition="25"
app:percentX="0.0"
app:percentY=".2" />
<!-- At 55, title should still be in place -->
<KeyPosition
app:motionTarget="@+id/title"
app:framePosition="55"
app:percentX="0" />
<!-- at 75, title is 50% to destination -->
<KeyPosition
app:motionTarget="@+id/title"
app:framePosition="75"
app:percentX=".5" />
<!-- Hide subtitle until 55 -->
<KeyAttribute
app:motionTarget="@+id/subtitle"
app:framePosition="55"
android:alpha="0" />
<!-- Hold subtitle in place until 55 -->
<KeyPosition
app:motionTarget="@+id/subtitle"
app:framePosition="55"
app:percentX="0" />
<!-- at 55, subtitle is 50% to destination -->
<KeyPosition
app:motionTarget="@+id/subtitle"
app:framePosition="75"
app:percentX=".5" />
<!-- "pop" icon out at 35, with some translation to make it visually stay in place -->
<KeyAttribute
app:motionTarget="@+id/icon"
app:framePosition="35"
Expand All @@ -40,34 +47,40 @@
android:translationY="30dp"
android:translationX="0dp"
app:curveFit="linear" />
<!-- Don't move icon along curve until 35 -->
<KeyPosition
app:motionTarget="@+id/icon"
app:framePosition="35"
app:percentX="0"
app:percentY="0"
app:curveFit="linear" />
<!-- Between 35 and 36 while icon is not visible, jump icon to it's final location -->
<KeyPosition
app:motionTarget="@+id/icon"
app:framePosition="36"
app:percentX="1"
app:percentY="1"
app:curveFit="linear" />
<!-- Translate icon a bit to make it "fill in" after jump -->
<KeyAttribute
app:motionTarget="@+id/icon"
app:framePosition="36"
android:translationY="-30dp"
android:translationX="20dp"
app:curveFit="linear" />
<!-- Animate the bottomCutSize to 0 -->
<KeyAttribute
app:motionTarget="@id/background"
app:framePosition="60">
<CustomAttribute app:attributeName="bottomCutSize" app:customDimension="0dp" />
</KeyAttribute>
<!-- animate the endCutSize to 200, a little before the end of animation -->
<KeyAttribute
app:motionTarget="@id/background"
app:framePosition="80">
<CustomAttribute app:attributeName="endCutSize" app:customDimension="200dp" />
</KeyAttribute>
<!-- bring the system bar overlay in slightly early (numbers decided visually) -->
<KeyPosition
app:motionTarget="@+id/systembar_overlay"
app:framePosition="45"
Expand All @@ -76,7 +89,8 @@
</KeyFrameSet>
</Transition>

<ConstraintSet android:id="@+id/start">
<!-- Start constraint set uses expanded_bottom and parent as bottom and top bounds -->
<ConstraintSet android:id="@+id/expanded">
<Constraint
android:id="@+id/title"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -128,7 +142,9 @@
app:layout_constraintEnd_toEndOf="parent" />
</ConstraintSet>

<ConstraintSet android:id="@+id/end" >
<!-- end constraint set uses collapsed_top and parent as top and bottom, with inset as
guideline -->
<ConstraintSet android:id="@+id/collapsed" >
<Constraint
android:id="@+id/title"
android:layout_height="wrap_content"
Expand Down

0 comments on commit a303777

Please sign in to comment.