Android 布局样式和主题

来源:互联网 发布:less.js下载 编辑:程序博客网 时间:2024/06/05 16:14

样式和主题

样式:可以指定控件的显示形式

样式的继承:

<style name="my_textview_style_small" parent="@style/my_textview_style">
也可以使用
<style name = "父类样式名.子类的样式名"></style>
这样就表示了样式的继承了

css 样式 ,通用的样式模板,继承 

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="my_textview_style">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#0000ff</item>
<item name="android:textSize">25sp</item>
</style>
<style name="my_textview_style_small" parent="@style/my_textview_style">
<item name="android:textSize">15sp</item>
</style>
<style name="my_textview_style.my_textview_style_verylarge" >
<item name="android:textSize">45sp</item>
</style>
</resources>
主题:主题和样式在声明的时候没有任何的区别,
样式和主题的区别: 在定义上没有任何区别, 区别是在使用上, 
样式的作用范围:作用在控件上(textView,ImageView,Button) 
主题的作用范围:作用在一个activity上,或者作用在整个应用程序上。
仿照系统的透明主题:
<style name="my_theme">
<item name="android:windowBackground">@color/trans</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
0 0
原创粉丝点击