您必须创建一个自定义主题并将其保存在某些目录中才能最终将此主题设置为应用程序的默认主题
首先,在values中添加一个themes.xml,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Any customizations for your app running on pre-3.0 devices here -->
</style>
</resources>
然后,在 res 目录中创建一个名为“values-v11”(Android 3.0+)的目录,并放置一个像这样的 theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
<!-- Any customizations for your app running on 3.0+ devices here -->
</style>
</resources>
最后在res目录下创建一个名为“values-v14”(Android 4.0+)的目录,并创建一个themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<!-- Any customizations for your app running on 4.0+ devices here -->
</style>
</resources>
借助 DeviceDefault,您的应用程序在任何公司(HTC Samsung ...)的任何设备(添加为 Android 4 创建的自定义主题)中始终看起来完美
编辑:三星的界面(TouchWiz)不尊重此功能,并且应用程序在三星的设备上将非常丑陋。最好放 Holo 主题:(
最后在你的manifest.xml中
<application
...
android:theme="@style/MyAppTheme">