【问题标题】:Set the textcolor of android.webkit.WebTextView class?设置android.webkit.Web TextView 类的文字颜色?
【发布时间】:2013-02-25 20:47:58
【问题描述】:

我有一种调查类型的表单,它会在用户按下提交后吐出回复。这是使用 webview 客户端,因此我可以在覆盖 URL 之前轻松修改 CSS。但是,按下提交后,样式有黑色字体(和其他不需要的东西)。有没有办法改变 WebTextView 的文字颜色?

最终,最好覆盖它,但看起来我不能:

WebTextView(Context context, WebView webView, int autoFillQueryId) {         super(context, null, com.android.internal.R.attr.webTextViewStyle);
     mWebView = webView;
     mMaxLength = -1;
     setAutoFillable(autoFillQueryId);
     // Turn on subpixel text, and turn off kerning, so it better matches
     // the text in webkit.
     TextPaint paint = getPaint();
     int flags = paint.getFlags() & ~Paint.DEV_KERN_TEXT_FLAG
             | Paint.SUBPIXEL_TEXT_FLAG | Paint.DITHER_FLAG;
     paint.setFlags(flags);

     // Set the text color to black, regardless of the theme.  This ensures
     // that other applications that use embedded WebViews will properly
     // display the text in password textfields.
     setTextColor(DebugFlags.DRAW_WEBTEXTVIEW ? Color.RED : Color.BLACK);

【问题讨论】:

    标签: java android android-webview


    【解决方案1】:

    有没有办法改变WebTextView的文字颜色?

    Android SDK 中没有WebTextView,因此无法修改。

    这是使用 webview 客户端,因此我可以在覆盖 URL 之前轻松修改 CSS。

    听起来您的问题是 CSS 最初应该是正确的,无论是对于您在提交此表单之前显示的页面还是之后显示的页面。 IOW,解决方案是从 HTML/CSS/JS 的角度正确处理它,您(可能)控制它。

    【讨论】:

    • 感谢您的回答。因为我没有访问权限,所以我最终没有对 css 做任何事情,但我只是最终序列化了表单 html 数据并使用带有 EditText 和 Button 的本机 android 控件将 POST 数据作为服务提交。
    猜你喜欢
    • 1970-01-01
    • 2012-09-13
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多