Professional Documents
Culture Documents
Eric Android Kotlin Unit 4
Eric Android Kotlin Unit 4
Controls
ANDROID KOTLIN
Android Kotlin Unit 4 : Controls
Also, we can use menu APIs to represent user actions and other
options in our android application activities.
We can simply define the menu and all its items in XML menu
resource instead of building the menu in the code and also load
menu resource as menu object in the activity or fragment used
in our android application.
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/mail"
android:icon="@drawable/ic_mail"
android:title="@string/mail" />
<item android:id="@+id/upload"
ERIC VASAVADA 3
Android Kotlin Unit 4 : Controls
android:icon="@drawable/ic_upload"
android:title="@string/upload"
android:showAsAction="ifRoom" />
<item android:id="@+id/share"
android:icon="@drawable/ic_share"
android:title="@string/share" />
</menu>
<menu>
It is the root element that helps in defining Menu in XML
file and it also holds multiple elements.
<item>
It is used to create a single item in the menu. It also contains
nested <menu> element in order to create a submenu.
<group>
It is optional and invisible for <item> elements to
categorize the menu items so they can share properties like
active state, and visibility.
ERIC VASAVADA 4
Android Kotlin Unit 4 : Controls
Android Context Menu is a floating menu that only appears
when the user clicks for a long time on an element and is useful
for elements that affect the selected content or context frame.
ERIC VASAVADA 6
Android Kotlin Unit 4 : Controls
The options menu provides users with access to various actions and
settings that they can perform within the app. Common items found
in an options menu include actions like "Save", "Edit", "Delete",
"Settings", and so on.
ERIC VASAVADA 7
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 8
Android Kotlin Unit 4 : Controls
Compared to options menus, popup menus offer more flexibility in
terms of customization and placement within the user interface.
Popup menus can be displayed either above or below the anchor
view, depending on the available space and the desired UI layout.
ERIC VASAVADA 9
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 12
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 13
Android Kotlin Unit 4 : Controls
Que 7: What is Seekbar in Android?
ERIC VASAVADA 14
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 15
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 16
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 17
Android Kotlin Unit 4 : Controls
1. Prominence: FABs are designed to stand out and draw the user's
attention. They often have a distinctive color or icon to indicate
their purpose.
ERIC VASAVADA 18
Android Kotlin Unit 4 : Controls
2. Floating: Unlike traditional buttons that are placed within the
layout hierarchy, FABs "float" above the content of the app, usually
positioned in the lower right corner. This positioning ensures that
the button remains visible and accessible even when the user scrolls
through the content.
ERIC VASAVADA 19
Android Kotlin Unit 4 : Controls
ERIC VASAVADA 20
Android Kotlin Unit 4 : Controls
Developers can populate a GridView with data using an adapter,
which is responsible for creating views for each item in the grid and
managing the data set. Android provides various built-in adapters,
such as ArrayAdapter and CursorAdapter, or developers can create
custom adapters to suit their specific needs.
ERIC VASAVADA 21