Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple HTML (or XML) to Android Native converter

I have a very simple data format that I want to frequently display that in my app. The first approach is using native android components like TextView, ImageView and TableLayout. But this approach makes me create a lot of different UIs. Second approach is to use WebView instead. This way I will lost speed. WebView is very powerful for such purposes but it kills UI responsiveness. The third way is to use a (very simple) HTML or XML and convert them to native android UI elements at runtime.

For example assume that I want to convert this simple html:

<div style="some_div_style">
    <p style="some_paragraph_style">A not-very-long-text comes here</p>
    <img src="..."/>
</div>

into this:

<LinearLayout style="@style/some_div_style">
    <TextView style="@style/some_paragraph_style" android:text="A not-very-long-text comes here"/>
    <ImageView android:src="..." .../>
</LinearLayout>   

at runtime.

Do you know any library for doing such HTML (or XML) converter?

like image 583
Ali Behzadian Nejad Avatar asked Dec 23 '14 06:12

Ali Behzadian Nejad


People also ask

Can I use HTML instead of XML in Android Studio?

yes it is possible you can design whole page in html and stored in Asset folder with image used,css,script folder,and in android activity you just open it in webView . Save this answer.

Why XML is used in Android instead of HTML?

Terminology. eXtensible Markup Language, or XML: A markup language created as a standard way to encode data in internet-based applications. Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace.


1 Answers

I think this is what you (or anyone need this) looking for:

squarede

Converts and optimizes pure HTML and SVG into the various standard Android layouts in XML. Easiest to use and also most accurate with support for CSS/SMIL animations. Compatible with Chrome and Safari.

And yes! I know that it is an old post.

like image 58
Top Systems Avatar answered Oct 02 '22 15:10

Top Systems