投入要素WebViews总是有相同的风格,如果强调了HTC设备是有、要素、风格、设备

由网友(没有梦想何必远方)分享简介:我目前正在写一个应用程序,它使用一个嵌入式的WebView以显示其内容还是从用户使用输入表单有时查询数据。在这些形式的输入域使用的是WebKit的CSS样式风格。I'm currently writing an app which uses an embedded WebView to display its con...

我目前正在写一个应用程序,它使用一个嵌入式的WebView以显示其内容还是从用户使用输入表单有时查询数据。在这些形式的输入域使用的是WebKit的CSS样式风格。

I'm currently writing an app which uses an embedded WebView to display its content or to sometimes query data from the user using input forms. The input fields in these forms are styled using -webkit-css Styles.

这工作正常的所有​​设备,到目前为止(在Nexus One上,LG的Optimus 500,三星Galaxy S测试),但与HTC Sense装置。在具有HTC Sense的设备,如果输入的元素被选中样式会丢失。使用输入:重点{} 在CSS没有帮助,HTC的设备与检测根本不理

This works fine on all Devices (tested on Nexus One, LG Optimus 500, Samsung Galaxy S) so far, except on Devices with HTC Sense. On Devices with HTC Sense the styling gets lost if the input element gets selected. Using input:focus {} in the css doesn't help, the HTC Devices with Sense simply ignore.

该图说明它的昵称当前选择,但仍应风格以同样的方式像Vorname和Nachname的。

This image illustrates it, the "Nickname" is currently selected but should still be styled the same way like "Vorname" and "Nachname" are.

任何想法,也许解决这个问题呢?

Any ideas to maybe workaround this problem?

下面是一个简单的HTML页面(根据要求)​​:

Here is a sample HTML page (upon request):

<html>
<head>
    <meta name="viewport" content="target-densitydpi=low-dpi" />
    <style type="text/css">
      input[type="number"],
      input[type="text"]{
    border: 1px solid #CDFF3C;
    background: #F3FECA;
    width: 220px;
    -webkit-border-radius: 4px;
        -webkit-box-shadow: inset 1px 1px 4px #AAA;
    -webkit-tap-highlight-color: rgba(205, 255, 60, 0.5);
      }
      body {
        background:#ebffb9;
        margin-right:0;
        margin-left:0;
        font-size: 14px;
      }
    </style>
</head>
<body>
<form name="data" action="/im/postdata" method="get" accept-charset="UTF-8">
  <p class="edit">
    <b>Vorname</b>
    <br/>
    <input type="text" name="3"/>
    </input>
  </p>
</form>
</body>
</html>

没有必要嵌入到这一点的应用程序,只需把它放在一个Web服务器上的某个地方,并使用内置的Web浏览器打开它。

No need to embed this into an app, simply put it on a web server somewhere and use the built in web browser to open it.

推荐答案

这可能与它保持CSS的时候专注于安卓2.2+?。

It could be related to: How can I style an HTML INPUT tag so it maintains CSS when focused on Android 2.2+?.

另外,你可以工作,围绕它通过使用含有的WebView本机应用程序,然后在RES /价值/的themes.xml主题应用到您的应用程序,它会覆盖webTextViewStyle用自己的风格:

Alternatively, you may be to work-around it by using a native app containing a WebView, and then apply a theme in res/values/themes.xml to your app which overrides webTextViewStyle with your own style:


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyTheme" parent="@android:syle/Theme">
        <item name="android:webTextViewStyle">@style/MyWebTextView</item>
    </style>
</resources>

然后在清单分配此为您的应用程序:

Then assign this to you app in the Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mywebapp" android:versionCode="1" android:versionName="1">
    <uses-permission android:name="android.permission.INTERNET" />

    <application android:icon="@drawable/icon" android:label="@string/app_name"
        android:theme="@style/MyTheme">
        .
        .
        .
    </application>
</manifest>

然后,只需加载HTML到您的WebView,看看文本输入控件采用了全新的风格。

Then simply load your html in to your WebView and see if the text input control has adopted the new style.

阅读全文

相关推荐

最新文章