Reputation: 9716
I want to customize text (font, size, color...) which is displayed on a picture. I decided to use WebView as I'm not sure how to use (and is it possible at all???) HTML/CSS inside a TextView. The problem is that a WebView has its own background(white) though which I can't see my picture. setBackgroundDrawable(null);
did not help.
Upvotes: 0
Views: 475
Reputation: 9716
OK, so I found the answer. If you want to make the background of WebView transparent, just write in your .xml file android:alpha="0"
. To retrieve HTML-tags in Android, implement a TagHandler interface. There is an example here.
Upvotes: 0
Reputation: 5435
Use an imageview and textview inside of an absolutelayout or relativelayout. Then align the two views to different sides of the layout and use margins and gravity to space them correctly. Using a webview for images and text when there is no need seems pointless if they are not on a webpage.
http://developer.android.com/resources/articles/layout-tricks-merge.html
To add a font to your project, create a new folder called "assets
" in your root. inside there creates a folder "fonts
" and in there, place your .ttf file. Here is a link:
How to add external fonts to android application
Upvotes: 2
Reputation: 7
You can try this out..
public class Hello extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.hello);
mWebView = (WebView) findViewById(R.id.webviewactive);
String text =
mWebView.loadData(text, "text/html", "utf-8");
mWebView.setBackgroundColor(0);
Upvotes: 0
Reputation: 46856
You might be able to use yourWebView.setBackgroundResource(R.drawable.yourImage);
But I am not 100% sure that WebViews support that method. Another option would be to put the Image in the html that you are using though. That might be the easiest way to go about making it look exactly how you want.
Upvotes: 0