Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Use GlassActionBar Library in Android App?

  • Last Updated : 23 Jul, 2021

GlassActionBar is an Android library that adds a glassy look to the action bar. It makes the view behind the action bar translucent, giving it a beautiful aesthetic. It also works with the three most popular action bar implementations: stock (API 11+), ActionBarCompat, and ActionBarSherlock. In this article, we will use the Java programming language to integrate this library into an Android app. A sample GIF is provided below to give you an idea of what we will do in this article.

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add the library dependency

Navigate to the Gradle Scripts > build.gradle(Module:app), add the library in the dependencies section, and sync the project.

dependencies {
      implementation 'com.github.manuelpeinado.glassactionbar:glassactionbar:0.3.0'

Step 3: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and refer to the following code. Below is the code for the activity_main.xml file. 


    <!--This layout contains the main layout below action bar-->
    <!--This LinearLayout contains children in vertical order-->
            android:src="@drawable/gfgicon" />
            android:textAppearance="@android:style/TextAppearance.Medium" />

Step 4: Working with the styles.xml file

Navigate to the app > res > values> styles.xml and refer to the following code. Below is the code for the styles.xml file. 


    <!--Adding background for GlassActionBar-->
    <style name="TranslucentActionBar" parent="android:Widget.ActionBar">
        <item name="android:background">@drawable/ab_transparent</item>

Step 5: Working with the themes.xml file

  • Navigate to the app > res > values
  • Right-click on values and select New > Values Resource File
  • A dialog box will appear now, then add the File Name as themes and press OK.
  • Below is the code for the themes.xml file.


<?xml version="1.0" encoding="utf-8"?>
    <style name="AppTheme" parent="android:Theme.Holo.Light">
    <!--Adding translucent theme for glassy effect -->
    <style name="AppTheme.TranslucentActionBar">
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:actionBarStyle">@style/TranslucentActionBar</item>

Step 6: Working with the AndroidManifest.xml file

Navigate to app > manifests > AndroidManifests.xml  and add Translucent Theme for action bar in the activity. 


Step 7: Working with the file

Go to the file and refer to the following code. Below is the code for the file. 


import android.os.Bundle;
import com.manuelpeinado.glassactionbar.GlassActionBarHelper;
public class MainActivity extends Activity {
    private GlassActionBarHelper helper;
    protected void onCreate(Bundle savedInstanceState) {
        // Adding glass action bar view to the activity
        helper = new GlassActionBarHelper().contentLayout(R.layout.activity_main);


Github Repository for the following project can be found here.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!