Skip to main content

Customize ActionBar | Android Dev

How to change;

     Actionbar color?
     Statusbar color?
     Statusbar text color?
     
**Set this style for the relevant activity


<style name="ThemeActionBar" parent="ThemeOverlay.AppCompat.Light">    <!-- title text color -->    <item name="android:textColorPrimary">@color/colorBlack</item>    <!-- subtitle text color -->    <item name="android:textColorSecondary">@color/colorBlack</item>    <!-- action menu item text color -->    <item name="actionMenuTextColor">@color/colorBlack</item>    <!-- action menu item icon color - only applies to appcompat-v7 icons :( -->    <item name="colorControlNormal">@color/colorBlack</item>
    <!-- enable actionbar -->
<item name="windowActionBar">true</item> <item name="windowNoTitle">false</item>
    <!-- actionbar color -->
<item name="colorPrimary">@color/colorWhite</item>
    <!-- statusbar color -->
<item name="colorPrimaryDark">@color/colorWhite</item>
    <!-- key element color -->
<item name="colorAccent">@color/colorAccent</item>
    <!-- background color -->
<item name="android:windowBackground">@color/colorBackground</item>
    <!-- status bar text/icon color set to dark (api23) -->
<item name="android:windowLightStatusBar">true</item></style>



How to enable;

     Actionbar ?
     backbutton ?

getSupportActionBar().show();getSupportActionBar().setDisplayHomeAsUpEnabled(true);
or
getActionBar().show();getActionBar().setDisplayHomeAsUpEnabled(true);



How to remove;

     Actionbar drop shadow ?
getActionBar().setElevation(0);



Comments

Popular posts from this blog

React material-ui [version1] TextField customize

React material-ui v0.x gives the opportunity to customize elements by overriding styles easily. When it comes to latest version v1, it becomes a bit difficult to do that similar as the earlier version. But they have given more options to customize elements by theming, overriding with classes and JSS. So you have to be a reactJs or Mui expert to understand those stuff with the documentation other than the earlier version. (This tutorial for react/ mui beginners to migrate from version 0.x) I will show you both version styling examples to do complete AtoZ customization to a TextField.

Defer loading of JavaScript

To prevent JavaScript from blocking page loading, we recommend using the HTML async attribute when loading JavaScript. For example: <script async src="my.js"> If your JavaScript resources use document.write, it is not safe to use asynchronous loading. We recommend that scripts that use document.write be rewritten to use a different technique. Additionally, when loading JavaScript asynchronously, if your page loads scripts that depend on one another, care must be taken to make sure that your application loads scripts in the proper dependency order. If the external scripts are small, you can include them directly into the HTML document. Inlining small files in this way allows the browser to proceed with rendering the page.