Last active
January 9, 2019 10:05
-
-
Save shimondoodkin/86e56b3351b704a05e53 to your computer and use it in GitHub Desktop.
styling v21 compatibility android actionbar
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
package com.doodkin.example; | |
import android.support.v7.app.ActionBarActivity; | |
import android.content.ActivityNotFoundException; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import android.view.View; | |
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
//add icon of application to actionbar (up button): | |
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_launcher); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
setContentView(R.layout.activity_main); | |
} | |
} |
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
<resources xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- | |
Base application theme, dependent on API level. This theme is replaced | |
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | |
--> | |
<style name="AppBaseTheme" parent="Theme.AppCompat.Light" > | |
<!-- | |
Theme customizations available in newer API levels can go in | |
res/values-vXX/styles.xml, while customizations related to | |
backward-compatibility can go here. | |
<item name="android:windowNoTitle">true</item> | |
--> | |
</style> | |
<!-- Application theme. --> | |
<style name="AppTheme" parent="AppBaseTheme"> | |
<!-- All customizations that are NOT specific to a particular API-level can go here. --> | |
<item name="colorPrimary">@color/primary</item> | |
<item name="colorPrimaryDark">@color/primary_dark</item> | |
<item name="colorAccent">@color/accent</item> | |
<item name="android:textColorPrimary">@color/text_primary</item> | |
<item name="android:textColor">@color/text_secondary</item> | |
<!-- <item name="android:navigationBarColor">@color/primary_dark</item> // v21--> | |
<item name="actionOverflowButtonStyle">@style/MyActionButtonOverflow</item> | |
</style> | |
<!--set image to settings menu button--> | |
<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow"> | |
<item name="android:src">@drawable/small_menu_button</item> | |
<item name="android:scaleType">centerInside</item> | |
<item name="android:paddingTop">14dp</item> | |
<item name="android:paddingBottom">14dp</item> | |
</style> | |
</resources> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="primary">#f2f2f2</color> | |
<color name="primary_dark">#f2f2f2</color> | |
<color name="accent">#D9D9D9</color> | |
<color name="text_primary">#D9000000</color> | |
<color name="text_secondary">#D9000000</color> | |
<!-- | |
original from example(blue),(my is light gray header and light gray body): | |
<color name="primary">#673ab7</color> | |
<color name="primary_dark">#512da8</color> | |
<color name="accent">#ffc400</color> | |
<color name="text_primary">#D9FFFFFF</color> | |
<color name="text_secondary">#D9000000</color> | |
--> | |
</resources> |
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
<resources> | |
<!-- | |
Base application theme for API 14+. This theme completely replaces | |
AppBaseTheme from BOTH res/values/styles.xml and | |
res/values-v11/styles.xml on API 14+ devices. | |
--> | |
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> | |
<!-- API 21 theme customizations can go here. --> | |
<item name="android:navigationBarColor">@color/primary_dark</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment