Skip to content

Commit 4c3e1d5

Browse files
committed
[Transitions] Fixed catalog errors for some demos.
* Music player controls expands to take the place of the title area by updating constraints to tie both view groups to the bottom of the album art. * Fixed container transform activity scrolling bug caused by window.setSharedElementsUseOverlay. Removed this as it has no effect on the demo. * Fixed shared axis fragment end layout not animating by setting the end fragments transition name on the root scroll view instead of the scroll view's inner layout * Added insets to shared axis controls to be visible above the navigation bar when in edge-to-edge mode Resolves #3247 PiperOrigin-RevId: 511764274
1 parent 3fb6bb2 commit 4c3e1d5

File tree

5 files changed

+68
-49
lines changed

5 files changed

+68
-49
lines changed

catalog/java/io/material/catalog/musicplayer/res/layout/cat_music_player_album_fragment.xml

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,52 @@
5858
app:layout_constraintStart_toStartOf="parent"
5959
app:layout_constraintTop_toTopOf="parent" />
6060

61+
<!-- Album Info Container. Use a Card to give its background an -->
62+
<!-- elevation overlay in dark theme. -->
63+
<com.google.android.material.card.MaterialCardView
64+
android:id="@+id/album_info_container"
65+
android:layout_width="match_parent"
66+
android:layout_height="196dp"
67+
app:cardBackgroundColor="?attr/colorPrimarySurface"
68+
app:strokeWidth="0dp"
69+
app:cardCornerRadius="0dp"
70+
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintStart_toStartOf="parent"
72+
app:layout_constraintTop_toBottomOf="@id/album_image">
73+
74+
<LinearLayout
75+
android:id="@+id/album_details"
76+
android:layout_width="match_parent"
77+
android:layout_height="match_parent"
78+
android:paddingStart="56dp"
79+
android:paddingEnd="16dp"
80+
android:paddingLeft="56dp"
81+
android:paddingRight="16dp"
82+
android:gravity="center_vertical"
83+
android:orientation="vertical">
84+
85+
<TextView
86+
android:id="@+id/album_title"
87+
android:layout_width="wrap_content"
88+
android:layout_height="wrap_content"
89+
android:ellipsize="end"
90+
android:maxLines="1"
91+
android:textAppearance="?attr/textAppearanceHeadline3"
92+
android:textColor="?attr/colorOnPrimarySurface"
93+
tools:text="Metamorphosis" />
94+
<TextView
95+
android:id="@+id/album_artist"
96+
android:layout_width="wrap_content"
97+
android:layout_height="wrap_content"
98+
android:ellipsize="end"
99+
android:maxLines="1"
100+
android:textAppearance="?attr/textAppearanceSubtitle1"
101+
android:textColor="?attr/colorOnPrimarySurface"
102+
tools:text="Sandra Adams" />
103+
104+
</LinearLayout>
105+
106+
</com.google.android.material.card.MaterialCardView>
61107
<!-- Music Player -->
62108
<androidx.constraintlayout.widget.ConstraintLayout
63109
android:id="@+id/music_player_container"
@@ -168,51 +214,6 @@
168214

169215
</androidx.constraintlayout.widget.ConstraintLayout>
170216

171-
<!-- Album Info Container. Use a Card to give its background an -->
172-
<!-- elevation overlay in dark theme. -->
173-
<com.google.android.material.card.MaterialCardView
174-
android:id="@+id/album_info_container"
175-
android:layout_width="match_parent"
176-
android:layout_height="196dp"
177-
app:cardBackgroundColor="?attr/colorPrimarySurface"
178-
app:layout_constraintEnd_toEndOf="parent"
179-
app:layout_constraintStart_toStartOf="parent"
180-
app:layout_constraintTop_toBottomOf="@id/music_player_container">
181-
182-
<LinearLayout
183-
android:id="@+id/album_details"
184-
android:layout_width="match_parent"
185-
android:layout_height="match_parent"
186-
android:paddingStart="56dp"
187-
android:paddingEnd="16dp"
188-
android:paddingLeft="56dp"
189-
android:paddingRight="16dp"
190-
android:gravity="center_vertical"
191-
android:orientation="vertical">
192-
193-
<TextView
194-
android:id="@+id/album_title"
195-
android:layout_width="wrap_content"
196-
android:layout_height="wrap_content"
197-
android:ellipsize="end"
198-
android:maxLines="1"
199-
android:textAppearance="?attr/textAppearanceHeadline3"
200-
android:textColor="?attr/colorOnPrimarySurface"
201-
tools:text="Metamorphosis" />
202-
<TextView
203-
android:id="@+id/album_artist"
204-
android:layout_width="wrap_content"
205-
android:layout_height="wrap_content"
206-
android:ellipsize="end"
207-
android:maxLines="1"
208-
android:textAppearance="?attr/textAppearanceSubtitle1"
209-
android:textColor="?attr/colorOnPrimarySurface"
210-
tools:text="Sandra Adams" />
211-
212-
</LinearLayout>
213-
214-
</com.google.android.material.card.MaterialCardView>
215-
216217
<com.google.android.material.floatingactionbutton.FloatingActionButton
217218
android:id="@+id/fab"
218219
android:layout_width="wrap_content"

catalog/java/io/material/catalog/transition/SharedAxisHelper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
import io.material.catalog.R;
2020

2121
import android.util.SparseIntArray;
22+
import android.view.View;
2223
import android.view.View.OnClickListener;
2324
import android.view.ViewGroup;
2425
import android.widget.Button;
2526
import android.widget.RadioGroup;
2627
import androidx.annotation.NonNull;
2728
import androidx.annotation.Nullable;
29+
import androidx.core.view.OnApplyWindowInsetsListener;
30+
import androidx.core.view.ViewCompat;
31+
import androidx.core.view.WindowInsetsCompat;
2832
import com.google.android.material.transition.MaterialSharedAxis;
2933

3034
/** A helper class that sets up and manages shared axis demo controls. */
@@ -46,6 +50,21 @@ public class SharedAxisHelper {
4650
backButton = controlsLayout.findViewById(R.id.back_button);
4751
nextButton = controlsLayout.findViewById(R.id.next_button);
4852
directionRadioGroup = controlsLayout.findViewById(R.id.radio_button_group_direction);
53+
ViewCompat.setOnApplyWindowInsetsListener(
54+
controlsLayout,
55+
new OnApplyWindowInsetsListener() {
56+
@NonNull
57+
@Override
58+
public WindowInsetsCompat onApplyWindowInsets(
59+
@NonNull View v, @NonNull WindowInsetsCompat insets) {
60+
v.setPadding(
61+
v.getPaddingLeft(),
62+
v.getPaddingTop(),
63+
v.getPaddingRight(),
64+
insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom);
65+
return insets;
66+
}
67+
});
4968
}
5069

5170
public void setNextButtonOnClickListener(@Nullable OnClickListener onClickListener) {

catalog/java/io/material/catalog/transition/TransitionContainerTransformStartDemoActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ public class TransitionContainerTransformStartDemoActivity extends DemoActivity
4646
protected void onCreate(@Nullable Bundle bundle) {
4747
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
4848

49-
// Set up shared element transition and disable overlay so views don't show above system bars
49+
// Set up shared element transition
5050
setExitSharedElementCallback(new MaterialContainerTransformSharedElementCallback());
51-
getWindow().setSharedElementsUseOverlay(false);
5251

5352
super.onCreate(bundle);
5453

catalog/java/io/material/catalog/transition/res/layout/cat_transition_shared_axis_end.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<ScrollView
1818
xmlns:android="http://schemas.android.com/apk/res/android"
1919
xmlns:app="http://schemas.android.com/apk/res-auto"
20+
android:id="@+id/end_root"
2021
android:layout_width="match_parent"
2122
android:layout_height="match_parent">
2223

2324
<LinearLayout
24-
android:id="@+id/end_root"
2525
android:layout_width="match_parent"
2626
android:layout_height="wrap_content"
2727
android:padding="16dp"

catalog/java/io/material/catalog/transition/res/layout/cat_transition_shared_axis_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:orientation="vertical"
2323
tools:targetApi="lollipop">
2424

25-
<FrameLayout
25+
<androidx.fragment.app.FragmentContainerView
2626
android:id="@+id/fragment_container"
2727
android:layout_width="match_parent"
2828
android:layout_height="0dp"

0 commit comments

Comments
 (0)