Android app with CSS [closed]
Questions asking us开发者_开发百科 to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionHow can I use CSS in my Android app?
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.
- Loading an Android resource into a webview
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.
- Comparison between Corona, Phonegap, Titanium
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.
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
精彩评论