简体   繁体   中英

Android select dropdown combobox in webview shows as white text on white background for API 17 and above

My Android app has a webview which displays an HTML form from a remote website. The HTML form includes a SELECT element with several OPTION elements. When the SELECT element is touched, the list of OPTION elements is shown. So far, everything sounds pretty normal.

Now, when using the Google API 15 and below, Android displays the list of options with black text on a white background. On Google API 17 and above they are displayed with white text on a white background, making them impossible to see until one of the options is clicked on.

Screenshot: http://i4.photobucket.com/albums/y140/primehalo/API15-vs-API17-940x640_zps26849382.png

I have tested this on real phones and on emulators and it happens on both. If I use the default Android web browser to access the same URL that is used by the webview, then the list of options is displayed as white text on a dark gray background.

Screenshot: http://i4.photobucket.com/albums/y140/primehalo/webbrowser-470x640_zpsc3d64b65.png

Does anyone have any ideas as to why it would be displaying white-on-white in my webview? Or any ideas on where to look?

I found that the text color set in my style.xml was causing the problem:

<style name="tabText" parent="@android:style/Theme.NoTitleBar">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textSize">18dip</item>
    <item name="android:tabWidgetStyle">@style/TabWidget</item>
</style>

When I changed the textColor to #000000 then the text showed up properly, black text on a white background. However, this caused the SELECT element to lose its borders. Not setting the textColor at all seems to make it work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM