【问题标题】:How to set the background color of a WebView to a hex value?如何将 WebView 的背景颜色设置为十六进制值?
【发布时间】:2012-06-19 07:28:23
【问题描述】:

如何将WebView 的背景颜色设置为十六进制值?我愿意通过main.xml 或以编程方式接受。

【问题讨论】:

    标签: android android-layout webview


    【解决方案1】:

    假设您在 XML 资源中定义了 WebView,您可以执行以下操作:

    WebView myWebView = (WebView) findViewById(R.id.myWebView);
    myWebView.setBackgroundColor(Color.parseColor("#000000"));
    

    【讨论】:

      【解决方案2】:

      在xml中:

      <WebView
      android:background = "#7CFC00"
      />
      

      绿色等。

      【讨论】:

        【解决方案3】:

        从 onCreate 试试这个:

        myWebView.setBackgroundColor(0x7CFC00);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-06-23
          • 2011-09-06
          • 1970-01-01
          • 2019-03-26
          • 2022-09-30
          • 1970-01-01
          • 2019-07-20
          相关资源
          最近更新 更多