AutoCompleteTextView drop down has different full screen and background color behavior in Android 4+ and Android 5+ -


currently, i'm using autocompletetextview, toolbar's component.

i want achieve following thing.

  1. have autocompletetextview's dropdown full screen, left-right margins.
  2. have autocompletetextview's dropdown background red.

i use following code achieve such behavior

// full screen, left-right margins. msearchsrctextview.setdropdownwidth(getresources().getdisplaymetrics().widthpixels);  int color = color.parsecolor("#ffff0000");  drawable drawable = msearchsrctextview.getdropdownbackground(); drawable.setcolorfilter(color, porterduff.mode.multiply);  // if use colordrawable, in android 4.3, drop down left-right margins gone. //colordrawable drawable = new colordrawable(color);  msearchsrctextview.setdropdownbackgrounddrawable(drawable); 

in android 4+, yields desired behavior (with left-right margins, pure red background)

enter image description here

in android 5+, yields undesired behavior (no margins, not pure red background)

enter image description here

i wondering, why there's such different behavior? how can have n feel (almost full screen left-right margins, pure red background) in android 5+, in android 4+?

the full workable code demonstrate problem can found here : https://github.com/yccheok/toolbar-experiment/tree/33b7bda84e7ca1b60f4d6d19b863d5f666adfb3d

after run project, type "fr" in autocompletetextview in different android, see different drop down behavior.

i have checked project.

add custom autocompletetextview in xmls:

    style="@style/myautocompletetextview" 

and styles.xml:

<style name="myautocompletetextview" parent="android:widget.autocompletetextview">     <item name="android:dropdownselector">?attr/listchoicebackgroundindicator</item>     <item name="android:popupbackground">@drawable/abc_popup_background_mtrl_mult</item>     <item name="android:background">?attr/edittextbackground</item>     <item name="android:textcolor">?attr/edittextcolor</item>     <item name="android:textappearance">?android:attr/textappearancemediuminverse</item> </style> 

why there difference?

for apis under lolipop got default autocompletetextview inherited different values lolipop.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -