Adding app bar to a single activity when it is removed from the styles.xml file

Add the following code into the .xml file

 <android.support.v7.widget.Toolbar  
     android:id="@+id/my_toolbar"  
     android:layout_width="match_parent"  
     android:layout_height="?attr/actionBarSize"  
     android:background="?attr/colorPrimary"  
     android:elevation="4dp"  
     android:theme="@style/ThemeOverlay.AppCompat.ActionBar"  
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>  

If you want to add a text into the app bar then add the following code into the onCreate class of the relevant activity.

 Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);  
     setSupportActionBar(myToolbar);  

Comments

Popular posts from this blog

Getting started with MySQL using wamp server

Java ADF surfing through pages using buttons

SQL vs ORM