Android Style.xml的应用详解及代码实现
更新时间:2016年10月26日 10:17:15 投稿:lqh
这篇文章主要介绍了Android Style.xml的应用详解及代码实现的相关资料,需要的朋友可以参考下
Style.xml的妙用
Style.xml之于Android犹如css之于Jsp
妙用
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/sensor" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
这样的布局文件是很正常的。但是不如这样好
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/all_match" android:orientation="vertical" > <TextView android:id="@+id/sensor" style="@style/all_fill" /> </LinearLayout>
省时省力,一眼还能看出是什么布局方式。只需要在Style.xml 中添加 这些代码即可
<style name="all_fill" > <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> </style> <style name="all_match" > <item name="android:layout_width">match_content</item> <item name="android:layout_height">match_content</item> </style> <style name="width_fill" > <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">match_content</item> </style> <style name="height_fill" > <item name="android:layout_width">match_content</item> <item name="android:layout_height">fill_parent</item> </style>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章
详解android使用ItemDecoration 悬浮导航栏效果
本篇文章主要介绍了Android 最流行的吸顶效果的实现及代码,非常具有实用价值,需要的朋友可以参考下。2017-01-01Crashlytics Android 异常报告统计管理(详解)
下面小编就为大家带来一篇Crashlytics Android 异常报告统计管理(详解)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-05-05Android studio 3.0 查看手机文件系统的方法(超简单)
本文给大家分享Android studio更新到3.0版本之后,查看手机文件系统的方法,需要的朋友参考下吧2017-11-11Android编程使用自定义shape实现shadow阴影效果的方法
这篇文章主要介绍了Android编程使用自定义shape实现shadow阴影效果的方法,涉及Android中xml文件布局的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下2015-11-11
最新评论