android:background is not working with WebView? - android

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?

If one can set WebView background color in xml layout the answer is "NO" and the reason behind is:
Set Background Color of WebView. (XML LAYOUT)
You load data on webView in activity class.
The background you set in the step 1 will be ignored and default color will be set.
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.

Related

How to get WebView to ignore css

I am trying to load a local HTML page in an Android Webview. This page contains some layouting using CSS. But I also noticed that the Webview has a setBackgroundColor() method in which you can set a background color. however this does not work when the CSS file also set a background color.
Does anyone know how to make the Android Webview to ignore these CSS style when I set my own background color?
What you could do is add style to your page with javascript:
webview.loadUrl("javascript:document.body.style.background = color;");
Call this after you have loaded your url or html.
PS I think if you ignored the CSS you would the get the default white background even if you set setBackGroundColor()
setBackGroundColor is a method that all Views have, that's the only reason WebView has it imo.

How to change my background of the screen for my view

I have simple job to do. I have to create an Help page for my android application. On that page I want to just put a full page of text of green color with some background image. Can anybody suggest me how can I do this in my XML file. Either in GraphicalLayoutMode or XML mode.
Please suggest what are the components required to this type of Help page...
android:background="#0abcde"
to set a color
android:background="#drawable/filename"
to set a image background.
use these tags for your layout parent view.

android custom button with default selector

I have a listview in which i have an image and text content getting populated from the java code.
I'm unable to get the default orange selector working on the image. The image is placed ontop of button as setBackgroundResource() from Java.
Can anyone help me with the same?
you could do change background by using drawable property of button in xml file. if you will use this setbackgroundresource() then it will ruin the effect of clicking on it. if u still want to use image as background source then u should create selector xml file for the button background.

Android WebView Background Color Problem

I have a webview in which I am showing some html text, for the same webview I have put background color as white both in xml and in the Java class. My problem is that if the text is short, only the part of the screen which has text appears with background color as white and after that the rest of the webview appears with black background color. Please help.
Have you changed the layout height and weight to fill parent ?
Also is the webview child of some other layout? It's properties also affect the layout parameters of the web view.
You seem to be using RGB instead of ARGB. Zero alpha.

android how to change the progressbar color programatically

How can you change the progressbar color from within the app. I already have it set in the XML but as the value gets within preset thresholds I need to change the color of the bar to alert the user. For the buttons I can set it like the example below. Is there a way to do with with the progressbar?
B.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.button2));
B.getBackground().setColorFilter( UserS.ColorBtnBack, PorterDuff.Mode.MULTIPLY);
I posted a tip as a comment on your other question, see http://colintmiller.com/2010/10/07/how-to-add-text-over-a-progress-bar-on-android/
Scroll down to "Bonus Tip", which discusses changing color. I guess you want a predefined set of colors, which you could then switch between using setProgressDrawable()
ProgressBar uses a LevelListDrawable with setProgressDrawable() to determine the color of the bar. You can try assembling a LevelListDrawable in Java, though I have never tried that -- I have only defined them via XML.

Categories

Resources