如题所述
<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å°±è¡äº
温馨提示:答案为网友推荐,仅供参考
第1个回答 2016-01-03
其实我们在style.xml中使用自定义属性的话,不需要写自定义控件的命名空间,我们只需要在style中使用命名控件的地方换成自定义控件的包名即可(注意:是包名,不带自定义控件的名字),如下:
<resources xmlns:android="" >
<style name="test" >
<item name="com.zhufuing:name_text">hello,world!</item>
</style>
</resources>本回答被提问者采纳
<resources xmlns:android="" >
<style name="test" >
<item name="com.zhufuing:name_text">hello,world!</item>
</style>
</resources>本回答被提问者采纳