Skip to content

Commit df3a708

Browse files
leticiarossipaulfthomas
authored andcommitted
[ExposedDropdownMenu] Fixed android:popupBackground not working in xml/styles for the AutoCompleteTextView.
Before, its value was being overwritten in code where we set the default popup background, so we should null it in the Material styles. PiperOrigin-RevId: 437813304
1 parent ffb64c1 commit df3a708

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

lib/java/com/google/android/material/textfield/DropdownMenuEndIconDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private void showHideDropdown(@Nullable AutoCompleteTextView editText) {
331331
}
332332

333333
private void setPopupBackground(@NonNull AutoCompleteTextView editText) {
334-
if (IS_LOLLIPOP) {
334+
if (IS_LOLLIPOP && editText.getDropDownBackground() == null) {
335335
int boxBackgroundMode = textInputLayout.getBoxBackgroundMode();
336336
if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_OUTLINE) {
337337
editText.setDropDownBackgroundDrawable(outlinedPopupBackground);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2022 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<!-- Base style for AutoCompleteTextView. You should use one of the sub-styles instead. -->
19+
<style name="Base.Widget.MaterialComponents.AutoCompleteTextView" parent="Base.V14.Widget.MaterialComponents.AutoCompleteTextView">
20+
<item name="android:popupBackground">@null</item>
21+
</style>
22+
</resources>

lib/java/com/google/android/material/textfield/res/values/styles.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@
200200
<item name="android:paddingBottom">13dp</item>
201201
</style>
202202

203-
<!-- Base style for AutoCompleteTextView. You should use one of the sub-styles instead. -->
204-
<style name="Base.Widget.MaterialComponents.AutoCompleteTextView" parent="Widget.AppCompat.AutoCompleteTextView">
203+
<!-- Base styles for AutoCompleteTextView. You should use one of the sub-styles instead. -->
204+
<style name="Base.V14.Widget.MaterialComponents.AutoCompleteTextView" parent="Widget.AppCompat.AutoCompleteTextView">
205205
<item name="enforceMaterialTheme">true</item>
206206
<item name="enforceTextAppearance">true</item>
207207
<item name="android:background">@null</item>
@@ -218,6 +218,8 @@
218218
<item name="android:popupElevation" tools:ignore="NewApi">@dimen/mtrl_exposed_dropdown_menu_popup_elevation</item>
219219
</style>
220220

221+
<style name="Base.Widget.MaterialComponents.AutoCompleteTextView" parent="Base.V14.Widget.MaterialComponents.AutoCompleteTextView"/>
222+
221223
<!-- Styles for the AutocompleteTextView to be used if an ExposedDropdownMenu style is being used. -->
222224
<style name="Widget.MaterialComponents.AutoCompleteTextView.FilledBox" parent="Base.Widget.MaterialComponents.AutoCompleteTextView">
223225
<!-- Padding values that total 34dp to visually match the spec. -->

0 commit comments

Comments
 (0)