Jimmy
Jimmy

Reputation: 10341

android:background is not working with WebView?

For some reason im unable to change the background color of an empty webView in xml using android:background. Although I could change it in java code using something like this:

myWebView.setBackgroundColor(Color.parseColor("#D4CAB4"));

But I prefer to do it in xml and I cant find the reason why android:background is not working?

Upvotes: 3

Views: 2045

Answers (1)

SALMAN
SALMAN

Reputation: 2031

If one can set WebView background color in xml layout the answer is "NO" and the reason behind is:

  1. Set Background Color of WebView. (XML LAYOUT)
  2. You load data on webView in activity class.
  3. The background you set in the step 1 will be ignored and default color will be set.
  4. The only method left is to set the background of WebView after the data is loaded.

I hope this can help you to understand the case here.

Upvotes: 1

Related Questions