简体   繁体   English

Android上使用Cordova / Phonegap的单选按钮

[英]Radio Buttons on Android using Cordova/Phonegap

I am using cordova to develop an app which runs on android, ios and windows phone. 我正在使用cordova开发可在android,ios和Windows Phone上运行的应用程序。 The radio buttons appear fine on all devices, apart from 1 android tablet (Samsung Galaxy Tab 2) i have, here is a screen shot of the radio buttons. 除了我拥有的1个android平板电脑(三星Galaxy Tab 2)以外,单选按钮在所有设备上均显示正常,这是单选按钮的屏幕截图。 As you can see, its hard to tell, but the top one is selected. 如您所见,它很难说,但最上面的一个已被选中。

在此处输入图片说明

Here is the same application running on my Samsung S4 phone, and the radio buttons look fine. 这是我的Samsung S4手机上运行的同一应用程序,单选按钮看起来不错。

在此处输入图片说明

The tablet is running android 4.2.2 and the phone is running 4.4.2 平板电脑正在运行android 4.2.2,而手机正在运行4.4.2

How can i get the radio buttons to look better on the tablet? 如何使单选按钮在平板电脑上看起来更好?

The reason this happens is probably because the newer Android version is running the Chrome webview while the older is running Samsung's old default stock browser. 发生这种情况的原因可能是因为较新的Android版本正在运行Chrome Webview,而较旧的版本正在运行Samsung的默认股票浏览器。 If you don't like the appearance of the radiobuttons you can style radiobuttons using CSS, here's a generic example that you could adapt yourself. 如果您不喜欢单选按钮的外观,则可以使用CSS设置单选按钮的样式,这是一个通用示例 ,您可以自行调整。

In order to conditionally set this styling for old versions of Android you could do something like this JavaScript: 为了有条件地为旧版本的Android设置此样式,您可以执行以下JavaScript:

var ua = navigator.userAgent;
if( ua.indexOf("Android") >= 0 )
{
  var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); 
  if (androidversion < 4.4)
  {
      // do whatever
  }
}

Of course you should adapt this more specifically to your example, but at least this is a start. 当然,您应该针对您的示例进行更具体的调整,但这至少是一个开始。 Good luck! 祝好运!

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

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