简体   繁体   English

Webview中的Android选择下拉组合框在API 17和更高版本的白色背景上显示为白色文本

[英]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. 我的Android应用程序有一个Web视图,该视图显示来自远程网站的HTML表单。 The HTML form includes a SELECT element with several OPTION elements. HTML表单包括带有几个OPTION元素的SELECT元素。 When the SELECT element is touched, the list of OPTION elements is shown. 触摸SELECT元素时,将显示OPTION元素的列表。 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. 现在,当使用Google API 15及更低版本时,Android在白色背景上以黑色文本显示选项列表。 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. 在Google API 17及更高版本中,它们在白色背景上显示为白色文本,因此在单击其中一个选项之前,无法看到它们。

Screenshot: http://i4.photobucket.com/albums/y140/primehalo/API15-vs-API17-940x640_zps26849382.png 截图: 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. 如果我使用默认的Android网络浏览器来访问网络视图所使用的相同URL,则选项列表在深灰色背景上显示为白色文本。

Screenshot: http://i4.photobucket.com/albums/y140/primehalo/webbrowser-470x640_zpsc3d64b65.png 截图: 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.xml中设置的文本颜色导致了问题:

<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. 当我将textColor更改为#000000时,文本将正确显示,白色背景上的黑色文本。 However, this caused the SELECT element to lose its borders. 但是,这导致SELECT元素失去边界。 Not setting the textColor at all seems to make it work as expected. 完全不设置textColor似乎可以使它按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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