安卓的主题资源文件,可以用于对Android应用的美化。
styles文件是主题资源文件。
定义一个主题资源格式如下:
@color/colorPrimary
@color/colorPrimaryDark
@color/colorAccent
false
@drawable/bg
引用主题资源可以在AndroidManifest资源中通过 android:theme="@style/AppTheme" 引用
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">
也可以在单独的Activity引用
android:theme="@style/bgTheme">
还可以通过Java代码引用
setTheme(R.style.bgTheme);
setContentView(R.layout.activity_main);
注意:如果使用Java代码应用要写在 setContentView(R.layout.activity_main) 之前
原文:/lzpq/p/12885237.html