style ,theme的区别
Style与Theme本质是相同的,可以说Theme是Style的一种,定义都是在res/values/style.xml,区别在于使用的地方不同
style: 作用于View
1. style定义
style作用于 View 直接引用即可, 举例如下
<style name="for_example">
<item name=" android:text">测试</item>
</style>
<Button
android:id="@+id/btn_action"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
//引用style
style="@style/for_example"
/>
2 .Theme :作用于<application>
或者<activity>
,举例如下:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
//引用主题
android:theme="@style/AppTheme">