Search code examples
javaandroidandroid-layoutandroid-widget

Can we use CSS in Android forms for android components?


is there anyway to use css for android controls, and can we make classes for similar controls.

Thanks Atif


Solution

  • Why do you want to define CSS for the Android views? First let me know the answer of this question, otherwise i would like to tell you that you can defines the same kind of styles inside the styles.xml file and then can implement for any views inside the xml layout file.

    For example:

    <?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>
    

    At initial level, you face some difficulty but later on as you became aware about defining xml layout file, you will be used to define styles for different views easily.

    Update:

    As per your comment below, i can say you are not knowing much more about styles and theme in android, so i would like to suggest you below links to know about styles/theme to apply in 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