Created
May 27, 2020 21:42
-
-
Save morenodoug/76a94a55ca831c75a677a7becbf55d0b to your computer and use it in GitHub Desktop.
customize action bar in android using style xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samples for styling android action bars: | |
http://android.cn-mirrors.com/training/basics/actionbar/styling.html | |
options to display in action bar : | |
http://android.cn-mirrors.com/reference/android/R.attr.html#displayOptions | |
xml tags must be inside res/style.xml | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
<!-- Used for settings preference theme --> | |
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item> | |
</style> | |
<style name="SunshineActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid"> | |
<item name="icon">@drawable/ic_logo</item> | |
<item name="displayOptions">useLogo|showHome</item> | |
</style> | |
<style name="AppTheme.Forecast"> | |
<item name="actionBarStyle">@style/SunshineActionBar</item> | |
</style> | |
in the android manifest we can set a theme to the app or activity through android:theme | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> | |
<!--The manifest entry for our MainActivity. Each Activity requires a manifest entry--> | |
<!-- Completed Use AppTheme.Forecast as the MainActivity's new theme --> | |
<activity | |
android:name=".MainActivity" | |
android:label="@string/app_name" | |
android:launchMode="singleTop" | |
android:theme="@style/AppTheme.Forecast"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN"/> | |
<category android:name="android.intent.category.LAUNCHER"/> | |
</intent-filter> | |
</activity> | |
... | |
</application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment