<resources> <!-- Base application theme. --> <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/sunshine_blue</item> <item name="colorPrimaryDark">@color/sunshine_dark_blue</item> </style> <!-- Main activity theme. --> <style name="ForecastTheme" parent="AppTheme"> <item name="actionBarStyle">@style/ActionBar.Solid.Sunshine.NoTitle</item> </style> <!-- main activity action bar styles --> <style name="ActionBar.Solid.Sunshine.NoTitle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="displayOptions">useLogo|showHome</item> <item name="logo">@drawable/ic_logo</item> </style> <!-- Style for forecast listview --> <style name="ForecastListStyle"> <!-- Here it's a stub. In screens of sufficient width, this style includes modifications for two-pane layout --> </style> </resources>
定义了一个ActionBarStyle,然后里面有两个属性,displayOptions和logo,这个在R.attr中有,以后还要慢慢学习这些设置
2.这些Theme和style定义好了之后,然后需要在Manifest文件中添加,比如下面,MainActivity设置Theme,不过最后显示的很好看,这是怎么显示的?
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:theme="@style/ForecastTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
3.突然有一阵点击详情,跳转,然后返回就回到点击的那个位置,但是加了V14style,突然不行了
4.
添加设置栏此节点的差异再来一个快速调整。我们将添加一个更新,使操作栏出现在设置中。三个主题分别是 AppTheme、ForecastTheme 和 SettingsTheme,我们将有 v21 和 v14 版本。 这是风格文件的更新 gist。在您的 SettingsActivity 的 AndroidManifest 标签中,您可能想添加设置主题:android:theme="@style/SettingsTheme"### 如果您在想为什么没有操作栏……操作栏没有出现的原因是 appcompat(提供向后兼容性的库)的当前版本为我们的程序设置风格。Appcompat 仅为来自未将 ActionBarActivity 划入子类的 ActionBarActivity 和 SettingsActivity 的活动添加操作栏。SettingsActivity 是 PreferenceActivity 的子类。那么我们为什么使用 PreferenceActivity?因为它是获得 Gingerbread 设备上运行的偏好 UI 的简单途径。通过使用来自 DarkActionBar 的主题为 SettingActivity 添加明确主题,我们就能够加回操作栏