You are on page 1of 4

NAME: Farrukh bashir awan

Sap_id:8622

MAD theory assignment

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.

The Components that can be included in the ActionBar are:

• Navigation control buttons / drawers

• App icon

• Title and subtitle

• Action button

• Action Overflow Menu

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

• Brand logo / app icon

• Title and subtitle

• Action menu items

• Multiple custom views such as text view and image view.

Question no 2:

How to change font of toolbar title in Android. [2 Marks]

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.

1: By Adding Child Text View in the activity_main.xml file

2: By Setting Text Font Programmatically.

Question no 3:

How to use Morphy toolbar library in Android. [2 Marks]

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.

Step 1: Create a new project

Step 2: Add JitPack

Step 3: Add library dependencies

Step 4: Manipulate the styles.xml file

Step 5: Manipulate the activity_main.xml file

Step 6: Work with the MainActivity.java file


Question no 4:

How to add custom toolbar background in Android. [2 Marks]

Solution:

Toolbar background for various methods.

The following method is displayed.

• Monochrome background

• Custom gradient background

• Image background

Custom gradient 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.

• Start Color: The first color of the background.

• EndColor: The second color of the background.

• Type: This determines whether the transition is linear or circular.

• 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.

• Add an image to the resource's Drawable folder.

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.

The next step is as follows:

Step 1: Create a new project

Step 2: Add dependencies and JitPack repositories

Go to app> Gradle Scripts> gradle.build (Module: app) and add the following dependency:

Step 3: Go to activity_main.xml and add the following code

Step 4: Implement RecyclerView

Step 5: Operation of MainActivity

Step 6: Manipulate themes.xml file

You might also like