我们可以在Android表单中使用CSS来安装Android组件吗?

Muh*_*gha 11 java android android-widget android-layout

无论如何使用css进行android控件,我们可以为类似的控件创建类.

谢谢Atif

Par*_*ani 13

为什么要为Android视图定义CSS?首先让我知道这个问题的答案,否则我想告诉你,你可以在styles.xml文件中定义相同类型的样式,然后可以实现xml布局文件中的任何视图.

例如:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#00FF00</item>
        <item name="android:typeface">monospace</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

在初始级别,您遇到一些困难但稍后在您了解定义xml布局文件时,您将习惯于轻松地为不同视图定义样式.

更新:

根据你下面的评论,我可以说你对android中的样式和主题了解不多,所以我想建议你在下面的链接知道在android中应用的样式/主题.

  1. http://developer.android.com/guide/topics/ui/themes.html
  2. http://android-pro.blogspot.com/2010/08/using-themes-and-styles-in-android.html


Lig*_*ght 5

也许你可以尝试Nativecss。这是一个库,您可以在 android 布局中使用类似 css 的选择器。

--------- 更新于2015年5月10日 ----------

或者一种全新的应用程序编写方式,NativeScript