Skip to content

Commit 1c5c054

Browse files
drchendsn5ft
authored andcommitted
[Dialog] Fix crashes when colorControlHighlight is a CSL
We set ?attr/colorControlHighlight as scroll indicators' background attribute. However, on older platforms this will crash the app due to Android expects a drawable or a plain color for the background attribute. Changes the view to TextView so it will be rendered as MaterialTextView, which supports app:backgroundTint with CSLs. Also changes the base background color to #1F000000 and the tint color to ?attr/colorForeground, which are aligned with what framework's alert dialog implementation is doing. Resolves #2455 PiperOrigin-RevId: 423917985
1 parent 9a5ec35 commit 1c5c054

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/java/com/google/android/material/dialog/res/layout/m3_alert_dialog.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
-->
1717
<androidx.appcompat.widget.AlertDialogLayout
1818
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:app="http://schemas.android.com/apk/res-auto"
1920
android:id="@+id/parentPanel"
2021
android:layout_width="match_parent"
2122
android:layout_height="wrap_content"
@@ -30,12 +31,14 @@
3031
android:layout_height="wrap_content"
3132
android:minHeight="48dp">
3233

33-
<View android:id="@+id/scrollIndicatorUp"
34+
<ImageView android:id="@+id/scrollIndicatorUp"
3435
android:layout_width="match_parent"
3536
android:layout_height="1dp"
3637
android:layout_gravity="top"
37-
android:background="?attr/colorControlHighlight"
38-
android:visibility="gone"/>
38+
android:background="#1f000000"
39+
android:visibility="gone"
40+
android:contentDescription="@null"
41+
app:backgroundTint="?android:attr/colorForeground"/>
3942

4043
<androidx.core.widget.NestedScrollView
4144
android:id="@+id/scrollView"
@@ -70,12 +73,14 @@
7073
</LinearLayout>
7174
</androidx.core.widget.NestedScrollView>
7275

73-
<View android:id="@+id/scrollIndicatorDown"
76+
<ImageView android:id="@+id/scrollIndicatorDown"
7477
android:layout_width="match_parent"
7578
android:layout_height="1dp"
7679
android:layout_gravity="bottom"
77-
android:background="?attr/colorControlHighlight"
78-
android:visibility="gone"/>
80+
android:background="#1f000000"
81+
android:visibility="gone"
82+
android:contentDescription="@null"
83+
app:backgroundTint="?android:attr/colorForeground"/>
7984

8085
</FrameLayout>
8186

0 commit comments

Comments
 (0)