Professional Documents
Culture Documents
Sap_id:8622
Question no 1:
Whats the difference between ActionBar, ToolBar and AppBar in Android. [2 Marks]
Solution:
AppBar is a design element of application activity and plays an important role. Its appearance gives the
application a clear identity. In addition, the title of the current activity is displayed, so users can easily
find out where they are in the application. The components included in the AppBar are:
• Title
• Menu button
ActionBar:
ActionBar is an element at the top of the activity screen. This is a salient feature of Android applications
and has a consistent presence in all activities.
• App icon
• Action button
Toolbar:
Toolbars are a type of ViewGroup that you can place in your activity's XML layout. It was introduced by
the Google Android team during the release of Android Lollipop (API 21). The toolbar is basically an
advanced successor to the action bar. Components that can be added to the toolbar:
• Navigation button / drawer or up button
Question no 2:
Solution
In an Android app, the toolbar title preset at the upper part of the application. There are two ways to
change the font of the Toolbar Title.
Question no 3:
Solution:
The Morphy Toolbar is a library where you can create custom toolbars with titles, subtitles, and images,
and you can also animate the view between transitions. This library is very easy to integrate and offers
multiple customization options.
Solution:
• Monochrome background
• Image background
Gradient colors can be created using more than one color. XML provides a cool way to create your own
gradient color that can be used as a background in many places. Follow these steps to create and set a
gradient background –
• Create an XML file in the Drawable folder of Resources. (Go to App> res> drawable> right-click> New>
Drawable Resource File and name the file Background)
• Create a shape inside the object and then place a gradient tag. • Add the following attributes.
• Angle: This sets the angle at which the two colors fade.
• Once the background XML is created, set it in the background attribute of the activity_main.xml file.
Image background:
Instead of color, you can also use an image as the background. For this, use the background attribute of
activity_main.xml again. See procedure.
Set the image in the drawable attribute of the toolbar in the activity_main.xml file.
• Make sure the image and toolbar are the same size.
Question no 5:
How to add custom toolbar background in Android. [2 Marks]
Solution:
The Waterfall Toolbar Library is an Android library developed to provide dynamic toolbar effects to
improve the look of your application.
This library actually makes a regular toolbar dynamic and increases or decreases its shadow as the
associated view scrolls.
Go to app> Gradle Scripts> gradle.build (Module: app) and add the following dependency: