如题所述
éè¦å¨styleä¸ä½¿ç¨å½åæ§ä»¶çå°æ¹æ¢æèªå®ä¹æ§ä»¶çå
åå³å¯(注æï¼æ¯å
åï¼ä¸å¸¦èªå®ä¹æ§ä»¶çåå)ï¼å¦ä¸ï¼
<resources xmlns:android="http://schemas.android.com/apk/res/android" >
<style name="test" >
<item name="com.zhufuing:name_text">hello,world!</item>
</style>
</resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android" >
<style name="test" >
<item name="com.zhufuing:name_text">hello,world!</item>
</style>
</resources>
温馨提示:答案为网友推荐,仅供参考
第1个回答 2016-01-18
<style name="ButtonGreen" parent="@android:style/Widget.Button">
<item name="android:textSize">18.0sp</item>
<item name="android:textColor">@drawable/skin_color_button</item>
<item name="android:background">@drawable/common_btn_green</item>
</style>
自定义style文件其实跟在layout里面直接写属性值是没有区别的,这样做的目的大概是为了更好的管理与规范代码,如上面的代码,直接放在layout中
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ButtonGreen" />
这样做的好处大概是有相同的button时不用再重复写相关属性了,直接调用相应的style就行了本回答被网友采纳
<item name="android:textSize">18.0sp</item>
<item name="android:textColor">@drawable/skin_color_button</item>
<item name="android:background">@drawable/common_btn_green</item>
</style>
自定义style文件其实跟在layout里面直接写属性值是没有区别的,这样做的目的大概是为了更好的管理与规范代码,如上面的代码,直接放在layout中
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ButtonGreen" />
这样做的好处大概是有相同的button时不用再重复写相关属性了,直接调用相应的style就行了本回答被网友采纳