安卓开发 之小白养成-UI美化

mac2025-03-02  5

Android样式 (Style)

作用:android中的样式和CSS样式作用相似,都是用于为界面元素定义显示风格,其包含一个或者多个view控件属性的集合。如:需要定义字体的颜色和大小等

注意:Theme是用于整个Application和Activity级别的,而Sytle是用于界面中的控件的(控件级别)。

 

1)在控件中使用样式:   style="@style/样式name"

2)定义样式:  样式定义位置res/values/styles.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>

    </style>

</resources>

最新回复(0)