Skip to content

Commit 996a484

Browse files
sadeghprodsn5ft
authored andcommitted
[dialog] Fix multichoice and singlechoice alert dialog in rtl mode of old api
Resolves #753 Co-authored-by:hunterstich <hunterstich@google.com> GIT_ORIGIN_REV_ID=f7475a875d5b9a30fa56928baa43cc2c513a1fe5 PiperOrigin-RevId: 283797976 (cherry picked from commit c4ce697)
1 parent 5b9402e commit 996a484

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,31 @@
1515
limitations under the License.
1616
-->
1717

18+
<!--
19+
This layout file is used by the AlertDialog when displaying a multi select list of items.
20+
21+
A left android:gravity will handle text alignemnt on API 16 and below while
22+
android:textAlignemnt will be used on 17+. A start android:gravity is not added
23+
to avoid text being aligned right while a drawable is aligned left in RTL configurations
24+
on API 16 and below.
25+
26+
app:drawableLeftCompat (and app:drawableStartCompat) used instead of android:drawableLeft
27+
(and android:drawableStart) because of bug on api 17 that aligned drawable both left and
28+
right when in RTL configurations
29+
-->
1830
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
31+
xmlns:app="http://schemas.android.com/apk/res-auto"
1932
android:id="@android:id/text1"
2033
android:layout_width="match_parent"
2134
android:layout_height="wrap_content"
2235
android:minHeight="?attr/listPreferredItemHeightSmall"
23-
android:gravity="center_vertical"
36+
android:gravity="left|center_vertical"
37+
android:textAlignment="viewStart"
2438
android:paddingLeft="@dimen/abc_select_dialog_padding_start_material"
2539
android:paddingRight="?attr/dialogPreferredPadding"
2640
android:paddingStart="@dimen/abc_select_dialog_padding_start_material"
2741
android:paddingEnd="?attr/dialogPreferredPadding"
28-
android:drawableLeft="?android:attr/listChoiceIndicatorMultiple"
29-
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
42+
app:drawableLeftCompat="?android:attr/listChoiceIndicatorMultiple"
43+
app:drawableStartCompat="?android:attr/listChoiceIndicatorMultiple"
3044
android:drawablePadding="20dp"
3145
android:ellipsize="marquee" />

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,31 @@
1515
limitations under the License.
1616
-->
1717

18+
<!--
19+
This layout file is used by the AlertDialog when displaying a single select list of items.
20+
21+
A left android:gravity will handle text alignemnt on API 16 and below while
22+
android:textAlignemnt will be used on 17+. A start android:gravity is not added
23+
to avoid text being aligned right while a drawable is aligned left in RTL configurations
24+
on API 16 and below.
25+
26+
app:drawableLeftCompat (and app:drawableStartCompat) used instead of android:drawableLeft
27+
(and android:drawableStart) because of bug on api 17 that aligned drawable both left and
28+
right when in RTL configurations
29+
-->
1830
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
31+
xmlns:app="http://schemas.android.com/apk/res-auto"
1932
android:id="@android:id/text1"
2033
android:layout_width="match_parent"
2134
android:layout_height="wrap_content"
2235
android:minHeight="?attr/listPreferredItemHeightSmall"
23-
android:gravity="center_vertical"
36+
android:gravity="left|center_vertical"
37+
android:textAlignment="viewStart"
2438
android:paddingLeft="@dimen/abc_select_dialog_padding_start_material"
2539
android:paddingRight="?attr/dialogPreferredPadding"
2640
android:paddingStart="@dimen/abc_select_dialog_padding_start_material"
2741
android:paddingEnd="?attr/dialogPreferredPadding"
28-
android:drawableLeft="?android:attr/listChoiceIndicatorSingle"
29-
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
42+
app:drawableLeftCompat="?android:attr/listChoiceIndicatorSingle"
43+
app:drawableStartCompat="?android:attr/listChoiceIndicatorSingle"
3044
android:drawablePadding="20dp"
3145
android:ellipsize="marquee" />

0 commit comments

Comments
 (0)