轉載請標明出處:http://blog.csdn.net/wu_wxc/article/details/53705924
本文出自【吳孝城的CSDN博客】
在values創建style文件
將相同的屬性寫到這里,其中name自己定義,引用時就是通過這個name來引用的
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--布局中的相同屬性-->
<style name="ControlStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">30sp</item>
<item name="android:layout_marginTop">10dp</item>
</style>
</resources>
現在我們在TextView中引用上面定義好的控件寬、高、字體大小、距離頂部多少dp時,就可以直接用
style=”@style/名字”
為引用了
<TextView
android:id="@+id/tv"
style="@style/ControlStyle" />
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。