Android style的继承方式 点(.)和parent详解及实例
Androidstyle的继承方式点(.)和parent详解及实例
一.概述
通过继承机制,可以利用已有的style来定义新的style。所定义的新的style型不仅拥有新定义的item,而且还同时拥有旧的item。我们称已存在的用来派生新的style为父style。由新定义的style,又称为子style。 比如:
<stylename="pickprof_guide_text"> <itemname="android:textSize">16.0sp</item> <itemname="android:textColor">#ff333333</item> </style> <stylename="pickprof_guide_text_small"parent="@style/pickprof_guide_text"> <itemname="android:textSize">13.0sp</item> </style>
二、两种继承方式
方式一:通过parent属性用来继承Android已经定义好的style。例如:
<stylename="XDialog"parent="android:Theme.Dialog"> <itemname="android:windowBackground">@drawable/pop_frame</item> </style>
方式二:如果要继承自定义的style,不需要通过parent属性,只要style的name以需要继承的style的name开始后跟新的style的name,中间用“.”隔开。注意:这种方式只适用与自定义的style继承。例如:
<!--Basestyleforanimations.Thisstylespecifiesnoanimations.--> <stylename="Animation"/> <!--Standardanimationsforanon-full-screenwindoworactivity.--> <stylename="Animation.Dialog"> <itemname="windowEnterAnimation">@anim/dialog_enter</item> <itemname="windowExitAnimation">@anim/dialog_exit</item> </style>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短