CSS Android App

How can I use CSS in my Android app?

+6
source share
2 answers

Native apps

If you want to create your own Android application, CSS support is not supported. Instead, android has its own mechanism.

Here's an introduction: http://developer.android.com/guide/topics/ui/themes.html

A complete list of options is available only in the source code.

Embedded application with local HTML

You can use WebViews in your native Android application to display the HTML that is packaged in the application, then you can use CSS like on any HTML site.

Using custom frameworks

There are frameworks that allow you to implement mobile applications with HTML, CSS and JavaScript. They compile it into their own applications to use phone features such as a gyroscope.

Web applications

Web applications are HTML websites optimized for mobile phones. Of course, you can use CSS for your site. An example of optimizing mobile devices is the offline mode, which uses HTML5 storage mechanisms to bridge connection breaks.

+18
source

If you want a CSS style focused on native Android apps, consider using the Scaloid library I wrote about: D

For instance:

new SVerticalLayout { style { case b: SButton => b.textColor(Color.GREEN).onClick(toast("Bang!")) case t: STextView => t.textSize(17 dip) case v => v.backgroundColor(Color.BLUE) } STextView("I am 17 dip tall") STextView("Me too") STextView("Oh, I am taller than you").textSize(24 dip) // overriding SEditText("Am I blue?") SButton("I am a green monster!") } 

It is simple, expressive and safe. This example came from the Scaloid blog:

http://blog.scaloid.org/2013/01/a-css-like-styling-on-android.html

0
source

Source: https://habr.com/ru/post/887594/


All Articles