目录
|
一.概述
通过继承机制,可以利用已有的style来定义新的style。所定义的新的style型不仅拥有新定义的item,而且还同时拥有旧的item。我们称已存在的用来派生新的style为父style。由新定义的style,又称为子style。 比如:
- <style name="pickprof_guide_text">
- <item name="android:textSize">16.0sp</item>
- <item name="android:textColor">#ff333333</item>
- </style>
- <style name="pickprof_guide_text_small" parent="@style/pickprof_guide_text">
- <item name="android:textSize">13.0sp</item>
- </style>
二、两种继承方式
方式一:通过parent属性用来继承android已经定义好的style。例如:
- <style name="XDialog" parent="android:Theme.Dialog">
- <item name="android:windowBackground">@drawable/pop_frame</item>
- </style>
- <!-- Base style for animations. This style specifies no animations. -->
- <style name="Animation" />
- <!-- Standard animations for a non-full-screen window or activity. -->
- <style name="Animation.Dialog">
- <item name="windowEnterAnimation">@anim/dialog_enter</item>
- <item name="windowExitAnimation">@anim/dialog_exit</item>
- </style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<include layout="@layout/title_bar" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="92dp"
android:orientation="vertical" >
<Button
style ="@style/Animation.Dialog"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
参考自博文: 点击打开链接