How to handle CSS code in my Android email app? - android

My app uses javamail to get the emails and then I use this Html android class to go through the message body and apply the html tags. But this class ignores CSS code, so if I look at an email which contains such code, it looks like this:
Basically 95% CSS code and 5% content at the bottom of it (not on picture). What are my options to solve this? I didn't really find anything useful so far. (I'm a beginner.)

The only thing native to Android that understands arbitrary HTML, like CSS, is WebView. For displaying received emails, use a WebView.

Related

Can i open svg syntax string into default android web browser as svg file on haxeflixel without server request/response manipulation?

Haxeflixel android targeting.
I need open text string with SVG syntax (XML) in default android browser, without server request/response actions. Something like just pushes text variable to the browser and display it as SVG file, like in the case when I do request and server response me SVG, but without internet and without creating the SVG file in the system storage (need additional permissions... in time of install apk...).
Is it possible?Any help will be good.
An actual browser window does not allow that, so I think what you want is a WebView. It uses the default Android browser engine and is what you see in most apps.
Since you are using HaxeFlixel and it, in turn, is based on OpenFL, you can use its extension-webview native extension:
var htmlString = <...>;
extension.webview.WebView.openHtml(htmlString);
You can also specify a onClose callback.
Note: it might be necessary to wrap the SVG in some HTML.

How link a js file to Android project - Eclipse

I am trying to link a js file to my android application. If it's possible. To be more specific I am developing an app using HTML(I don’t need help with this part) and I want to get my template working, it has mixed parts of html, css and javascript. This is what I have so far at the head of my sheet. ( I don’t know how to make code appear on here, I do have the < & /> in the original.
link rel="javascript" href="java2/jquery/mobile-slide-menu.js"
script type="text/javascript" src="java2/jquery-mobile-slide-menu.js"
This is what I am trying to make:
http://jsfiddle.net/gh/gist/jquery/1.9.1/5624435/
Is it possible to have html,css and javascript in one page or do I have to link them for them to work.
Let me know if you need more information.
You can do it either way as you are not using the webview javascript bridge directly it does nto matter which way you choose
Your choice will depend on which way you want to keep track of changes in the javascript and html css combination ..separately through different files or one single html file

Android UI : from html to XML

I've developped an application using XML Eclipse tool too build my UI.
Now, i'd like to use a tool like Axure to create a "nicer" interface.
My problem is : is there an easy way to switch from XML to HTML (because Axure is producting HTML file from Wireframe design) ?
And if not, how to "plug" HTML file to the existing application (which is using R.layout.xxx or R.id.xxx to access displayed elements).
I'm quite new in Android by the way...
thanks !
You can't really do what you describe. The way Android layout is specified in XML cannot be compared at all to HTML for websites. Besides, Axure is a mock-up tool. It creates interactive mockups and prototypes - not final solutions for anything.
If you really want to use Axure, perhaps you would want to go for web apps with something like PhoneGap - they are written in HTML and JavaScript, but have less possibilities.

Webview vs. Native Client

I was trying to display a webpage of a url on a plain WebView, and some of the images are not showing. However, everything shows up fine in the browser for the simulator.
Is there a difference between the rendering via WebView vs. the Android 2.3 Browser?
There are several things added to the Android browser. They add things in to handle JavaScript, to handle switching to native functionality for videos, etc. Luckily the Browser is open source so you can get the Android code base and see what they do.
Yes could be a difference. If you are passing the web text-plain to the webview directly it doesn't understand the images which are references depending the local path instead the goblal path reference.
I mean, if you have a <img src="/images/image.png" /> here you are referencing depending on your directory, and the browser try to look up image.png into your root, and if you have <img src="http://www.whatever.com/images/image.png" /> then you are referencing it globaly. So I think this is the main that you could have.

How does one change fonts in web pages for Android?

I'm making a simple browser based game using Javascript and HTML4. I have a single page and only two or three text blocks, so I want to avoid a separate style sheet if possible. I am happy to use Android's built in "Droid Serif" But Android ignores this and always defaults to "Droid Sanserif".
Stacoverflow has plenty of advice on adding custom fonts, but I can't find anything on accessing built in fonts.
I define the font-family within a div that surrounds the text. I tried posting the HTML here, but stackoverflow interprets it as formatting and just shows the result, not the code.
My html works fine in all regular browsers, and works fine in Android if I use Google's online fonts, so the structure of the HTML must be fine. But "Droid Serif" and all other font instructions are ignored. Any ideas how to make it behave?
I am assuming you mean that you have a local font file on the device and want to access it through a WebView? The best way is through a ContentProvider, it can serve local assets to a webview including fonts. Here's how to setup the ContentProvider: http://responsiveandroid.com/2012/02/20/serving-android-webview-resources-with-content-providers.html . There are example there for javascript, image files and css files. Following the structure from the tutorial, to get a font you would use something like
#font-face {
font-family: MyFont;
src: url("content://com.github.browep.lfcp/MyFont.ttf")
}
and it would be served from the local filesystem.

Categories

Resources