How can I use CSS in my Android app?
-
11Perhaps instead of closing, we should edit the question to be closer to "How do I apply styles in Android?" This is a valid question with a valid answer :) – jb. Jul 28 '15 at 23:32
-
3"off topic" ???? what!! – dsdsdsdsd May 12 '16 at 15:17
2 Answers
Native Apps
If you want to style a native android app, there is no support for CSS. Instead android has it's own mechanism.
Here's an introduction: http://developer.android.com/guide/topics/ui/themes.html
The complete list of options is only available at the source code.
Native App with local HTML
You may use WebViews in your native Android app, to display HTML which is packaged with the app, then you can use CSS like in any HTML site.
Using special frameworks
There are frameworks which enable you to implement mobile apps with HTML, CSS and JavaScript. They compile it into native apps to allow usage of phone features like gyroscope.
Web Apps
Web Apps are HTML sites, which are optimized for mobile phones. Of course you can use CSS for your site. An example for mobile optimizations is an offline mode, which uses HTML5's storage mechanisms to bridge connection gaps.

- 1
- 1

- 7,291
- 6
- 50
- 75
-
2I would discourage people from trying to bring literal html or css into a android environment, simply because if you have arrived at android development (or java), learn the android way ... then in the future, when you are an expert in android ways, and you find yourself in a need to import another 'language', you will be more than qualified to do so .. – dsdsdsdsd May 12 '16 at 15:21
If you want CSS-like style guiding for Android native apps, consider using Scaloid library, which is I wrote :D
For example:
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 type-safe. This example came from the Scaloid blog:
http://blog.scaloid.org/2013/01/a-css-like-styling-on-android.html

- 1,247
- 1
- 10
- 24
-
This seems to be an interesting project but what happened. no code commits after 2016. – xpioneer Jan 20 '22 at 07:02