Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the background color of a WebView to a hex value?

How do I set the background color of a WebView to a hexadecimal value? I am open to either via main.xml or programmatically.

like image 658
Jason Ching Avatar asked Jun 19 '12 07:06

Jason Ching


People also ask

What is a hex background color?

Background-color values can be expressed in hexadecimal values such as #FFFFFF, #000000, and #FF0000. Background-color values can be expressed using rgb such as rgb(255,255,255), rgb(0,0,0), and rgb(255,0,0). Background-color values can be expressed as named colors such as white, black, and red.

How do you make a hex color in CSS?

A hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and BB (blue) hexadecimal integers specify the components of the color.

How do I color a cell in Excel based on hex value?

But you can also use Format Cells and the Fill Tab, Click More Fill, then Custom and you can type in the Hex at the bottom and it will give you the Colours as well as the RGB numbers. You could also then apply Conditional Formatting so when a HEX number is used it colours the cell automatically for you.


2 Answers

Assuming you have defined your WebView in an XML resource, you can do the following:

WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor("#000000"));
like image 130
Smi Avatar answered Nov 10 '22 00:11

Smi


In xml:

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

for green etc..

like image 41
Archie.bpgc Avatar answered Nov 09 '22 23:11

Archie.bpgc