Skip to content

Commit 0e49338

Browse files
committed
updates based on feedback: changing box to button and changing the size and color of button for more pronounce transition
1 parent 57140be commit 0e49338

File tree

8 files changed

+46
-97
lines changed

8 files changed

+46
-97
lines changed

samples/user-interface/predictiveback/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ override fun onCreateView(savedInstanceState: Bundle?) {
239239
```
240240
## setCustomAnimations
241241

242-
Use setEnterTransition, setExitTransition, setReenterTransition, setReturnTransition,
243-
setSharedElementEnterTransition, setSharedElementReturnTransition instead of setCustomAnimations
242+
Use `setEnterTransition`, `setExitTransition`, `setReenterTransition`, `setReturnTransition`,
243+
`setSharedElementEnterTransition`, `setSharedElementReturnTransition` instead of `setCustomAnimations`
244244
where possible.
245245

246-
However, if you are using setCustomAnimations, here's a code sample showing
246+
However, if you are using `setCustomAnimations`, here's a code sample showing
247247
predictive back working with animators and fragment manager.
248248

249249
```kotlin

samples/user-interface/predictiveback/src/main/java/com/example/platform/ui/predictiveback/PBSetCustomAnimationsFirstFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PBSetCustomAnimationsFirstFragment : Fragment() {
3636
_binding = FragmentSetCustomAnimationsBinding
3737
.inflate(inflater, container, false)
3838

39-
binding.box.setOnClickListener {
39+
binding.button.setOnClickListener {
4040
parentFragmentManager.commit {
4141
setCustomAnimations(
4242
android.R.animator.fade_in, // enter

samples/user-interface/predictiveback/src/main/res/animator/fade_in.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
2-
~ Copyright 2023 The Android Open Source Project
2+
~ Copyright 2024 The Android Open Source Project
33
~
44
~ Licensed under the Apache License, Version 2.0 (the "License");
55
~ you may not use this file except in compliance with the License.
@@ -13,11 +13,8 @@
1313
~ See the License for the specific language governing permissions and
1414
~ limitations under the License.
1515
-->
16-
17-
<set xmlns:android="http://schemas.android.com/apk/res/android">
18-
<alpha
19-
android:duration="@android:integer/config_shortAnimTime"
20-
android:interpolator="@android:anim/decelerate_interpolator"
21-
android:fromAlpha="1"
22-
android:toAlpha="0" />
23-
</set>
16+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
17+
android:shape="rectangle">
18+
<solid android:color="#4285F4" />
19+
<corners android:radius="20dp" />
20+
</shape>
Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2023 The Android Open Source Project
3+
~ Copyright 2024 The Android Open Source Project
44
~
55
~ Licensed under the Apache License, Version 2.0 (the "License");
66
~ you may not use this file except in compliance with the License.
@@ -22,40 +22,13 @@
2222
android:layout_height="match_parent"
2323
tools:context=".PBSetCustomAnimationsActivity">
2424

25-
<TextView
26-
android:id="@+id/title"
27-
android:layout_width="wrap_content"
28-
android:layout_height="wrap_content"
29-
android:text="@string/cross_activity_header"
30-
android:textAppearance="?attr/textAppearanceTitleMedium"
31-
android:textSize="24sp"
32-
app:layout_constraintEnd_toEndOf="parent"
33-
app:layout_constraintStart_toStartOf="parent"
34-
app:layout_constraintTop_toTopOf="parent" />
35-
36-
37-
<!-- Your existing views -->
3825
<FrameLayout
3926
android:id="@+id/fragment_container"
40-
android:layout_width="406dp"
41-
android:layout_height="572dp"
27+
android:layout_width="0dp"
28+
android:layout_height="0dp"
4229
app:layout_constraintBottom_toBottomOf="parent"
4330
app:layout_constraintEnd_toEndOf="parent"
44-
app:layout_constraintHorizontal_bias="0.0"
4531
app:layout_constraintStart_toStartOf="parent"
46-
app:layout_constraintTop_toBottomOf="@+id/title"
47-
app:layout_constraintVertical_bias="0.173">
48-
49-
<!-- <View-->
50-
<!-- android:id="@+id/box_view"-->
51-
<!-- android:layout_width="100dp"-->
52-
<!-- android:layout_height="100dp"-->
53-
<!-- android:layout_gravity="center"-->
54-
<!-- android:background="@android:color/holo_blue_light"-->
55-
<!-- app:layout_constraintTop_toTopOf="parent"-->
56-
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
57-
<!-- app:layout_constraintStart_toStartOf="parent" />-->
58-
59-
</FrameLayout>
32+
app:layout_constraintTop_toTopOf="parent" />
6033

6134
</androidx.constraintlayout.widget.ConstraintLayout>

samples/user-interface/predictiveback/src/main/res/layout/fragment_set_custom_animations.xml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,24 @@
2222
android:layout_margin="16dp"
2323
tools:context=".PBSetCustomAnimationsFirstFragment">
2424

25-
<!-- <TextView-->
26-
<!-- android:id="@+id/title"-->
27-
<!-- android:layout_width="wrap_content"-->
28-
<!-- android:layout_height="wrap_content"-->
29-
<!-- android:text="@string/cross_activity_header"-->
30-
<!-- android:textAppearance="?attr/textAppearanceTitleMedium"-->
31-
<!-- android:textSize="24sp"-->
32-
<!-- app:layout_constraintEnd_toEndOf="parent"-->
33-
<!-- app:layout_constraintStart_toStartOf="parent"-->
34-
<!-- app:layout_constraintTop_toTopOf="parent" />-->
25+
<TextView
26+
android:id="@+id/title"
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:text="Fragment A"
30+
android:textAppearance="?attr/textAppearanceTitleMedium"
31+
android:textSize="24sp"
32+
app:layout_constraintEnd_toEndOf="parent"
33+
app:layout_constraintStart_toStartOf="parent"
34+
app:layout_constraintTop_toTopOf="parent" />
3535

36-
<View
37-
android:id="@+id/box"
36+
<Button
37+
android:id="@+id/button"
3838
android:layout_width="300dp"
39-
android:layout_height="300dp"
40-
android:background="@drawable/box"
39+
android:layout_height="100dp"
40+
android:background="@drawable/button"
41+
android:text="Click Me!"
42+
android:textColor="@android:color/white"
4143
app:layout_constraintBottom_toBottomOf="parent"
4244
app:layout_constraintEnd_toEndOf="parent"
4345
app:layout_constraintStart_toStartOf="parent"
@@ -53,8 +55,8 @@
5355
android:textAppearance="?attr/textAppearanceBodyMedium"
5456
android:textSize="16sp"
5557
app:layout_constraintBottom_toBottomOf="parent"
56-
app:layout_constraintEnd_toEndOf="@+id/box"
57-
app:layout_constraintStart_toStartOf="@+id/box"
58-
app:layout_constraintTop_toBottomOf="@+id/box" />
58+
app:layout_constraintEnd_toEndOf="@+id/button"
59+
app:layout_constraintStart_toStartOf="@+id/button"
60+
app:layout_constraintTop_toBottomOf="@+id/button" />
5961

6062
</androidx.constraintlayout.widget.ConstraintLayout>

samples/user-interface/predictiveback/src/main/res/layout/fragment_set_custom_animations_second.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222
android:layout_margin="16dp"
2323
tools:context=".PBSetCustomAnimationsFirstFragment">
2424

25-
<!-- <TextView-->
26-
<!-- android:id="@+id/title"-->
27-
<!-- android:layout_width="wrap_content"-->
28-
<!-- android:layout_height="wrap_content"-->
29-
<!-- android:text="@string/cross_activity_header"-->
30-
<!-- android:textAppearance="?attr/textAppearanceTitleMedium"-->
31-
<!-- android:textSize="24sp"-->
32-
<!-- app:layout_constraintEnd_toEndOf="parent"-->
33-
<!-- app:layout_constraintStart_toStartOf="parent"-->
34-
<!-- app:layout_constraintTop_toTopOf="parent" />-->
25+
<TextView
26+
android:id="@+id/title"
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:text="Fragment B"
30+
android:textAppearance="?attr/textAppearanceTitleMedium"
31+
android:textSize="24sp"
32+
app:layout_constraintEnd_toEndOf="parent"
33+
app:layout_constraintStart_toStartOf="parent"
34+
app:layout_constraintTop_toTopOf="parent" />
3535

3636
<View
3737
android:id="@+id/box"
38-
android:layout_width="300dp"
39-
android:layout_height="300dp"
38+
android:layout_width="350dp"
39+
android:layout_height="350dp"
4040
android:background="@drawable/box"
4141
app:layout_constraintBottom_toBottomOf="parent"
4242
app:layout_constraintEnd_toEndOf="parent"

samples/user-interface/predictiveback/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
<string name="sharedElementTransitionText">Swipe back to see a shared element Predictive Back transition.</string>
3131
<string name="fragment_material_shared_axis_body">Swipe back to see a Material Shared Axis transition.</string>
3232
<string name="setCustomAnimations_body">Swipe back to see a setCustomAnimations transition.</string>
33-
<string name="setCustomAnimations_desc">Click on the box</string>
33+
<string name="setCustomAnimations_desc">Click on the button</string>
3434

3535
</resources>

0 commit comments

Comments
 (0)