Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Android User Interface
Android - UI Layouts
The basic building block for user interface is a View object which is
created from the View class and occupies a rectangular area on the
screen and is responsible for drawing and event handling. View is the
base class for widgets, which are used to create interactive UI
components like buttons, text fields, etc.
LAYOUT PARAMS
XML file having LinearLayout
Once your layout has created, you can load the layout resource from
your application code, in your Activity.onCreate() callback
implementation
Android Layout Types
• Linear Layout
• Relative Layout
• Table Layout
• Absolute Layout
• Frame Layout
• List View
• Grid View
Linear Layout
• LinearLayout is a view group that
aligns all children in a single
direction, vertically or
horizontally.
Relative Layout
• RelativeLayout is a view group
that displays child views in
relative positions.
Absolute Layout
• An Absolute Layout lets you
specify exact locations (x/y
coordinates) of its children.
Absolute layouts are less flexible
and harder to maintain than
other types of layouts without
absolute positioning.
List View
• ListView is a view group that
displays a list of scrollable items.
Grid View
• GridView is a ViewGroup that
displays items in a two-
dimensional, scrollable grid.
Table Layout
• TableLayout is a view that groups
views into rows and columns.
Frame Layout
• The FrameLayout is a
placeholder on screen that you
can use to display a single view.
Layout Attributes
• android:id
• android:layout_width
• android:layout_height
• android:layout_marginTop
• android:layout_gravity
• android:layout_weight
• android:layout_x
• android:paddingRight
• android:layout_width
Android - UI Controls
• Input controls are the interactive components in your app's user
interface. Android provides a wide variety of controls you can use in
your UI, such as buttons, text fields, seek bars, check box, zoom
buttons, toggle buttons, and many more.
vertical layout with a text view and a button
Android UI Controls
• TextView
• EditText
• AutoCompleteTextView
• Button
• ImageButton
• CheckBox
• ToggleButton
• RadioButton
Create UI Controls
• To create a UI Control/View/Widget you will have to define a
view/widget in the layout file and assign it a unique ID as follows −
Android - Event Handling
• Events are a useful way to collect data about a user's interaction
with interactive components of Applications.Like button presses or
screen touch etc. The Android framework maintains an event queue
as first-in, first-out (FIFO) basis. You can capture these events in your
program and take appropriate action as per requirements.
Android Event Management
• Event Listeners
• Event Listeners Registration
• Event Handlers
Event Listeners
• An event listener is an interface in the View class that contains a
single callback method. These methods will be called by the Android
framework when the View to which the listener has been registered is
triggered by user interaction with the item in the UI.
Event Listeners Registration
• Event Registration is the process by which an Event Handler gets
registered with an Event Listener so that the handler is called when
the Event Listener fires the event.
Event Handlers
• When an event happens and we have registered an event listener for
the event, the event listener calls the Event Handlers, which is the
method that actually handles the event.
Design By Md Shakib Hasan
Daffodil International University

More Related Content

Android User Interface

  • 2. Android - UI Layouts The basic building block for user interface is a View object which is created from the View class and occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components like buttons, text fields, etc.
  • 4. XML file having LinearLayout
  • 5. Once your layout has created, you can load the layout resource from your application code, in your Activity.onCreate() callback implementation
  • 6. Android Layout Types • Linear Layout • Relative Layout • Table Layout • Absolute Layout • Frame Layout • List View • Grid View
  • 7. Linear Layout • LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
  • 8. Relative Layout • RelativeLayout is a view group that displays child views in relative positions.
  • 9. Absolute Layout • An Absolute Layout lets you specify exact locations (x/y coordinates) of its children. Absolute layouts are less flexible and harder to maintain than other types of layouts without absolute positioning.
  • 10. List View • ListView is a view group that displays a list of scrollable items.
  • 11. Grid View • GridView is a ViewGroup that displays items in a two- dimensional, scrollable grid.
  • 12. Table Layout • TableLayout is a view that groups views into rows and columns.
  • 13. Frame Layout • The FrameLayout is a placeholder on screen that you can use to display a single view.
  • 14. Layout Attributes • android:id • android:layout_width • android:layout_height • android:layout_marginTop • android:layout_gravity • android:layout_weight • android:layout_x • android:paddingRight • android:layout_width
  • 15. Android - UI Controls • Input controls are the interactive components in your app's user interface. Android provides a wide variety of controls you can use in your UI, such as buttons, text fields, seek bars, check box, zoom buttons, toggle buttons, and many more.
  • 16. vertical layout with a text view and a button
  • 17. Android UI Controls • TextView • EditText • AutoCompleteTextView • Button • ImageButton • CheckBox • ToggleButton • RadioButton
  • 18. Create UI Controls • To create a UI Control/View/Widget you will have to define a view/widget in the layout file and assign it a unique ID as follows −
  • 19. Android - Event Handling • Events are a useful way to collect data about a user's interaction with interactive components of Applications.Like button presses or screen touch etc. The Android framework maintains an event queue as first-in, first-out (FIFO) basis. You can capture these events in your program and take appropriate action as per requirements.
  • 20. Android Event Management • Event Listeners • Event Listeners Registration • Event Handlers
  • 21. Event Listeners • An event listener is an interface in the View class that contains a single callback method. These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI.
  • 22. Event Listeners Registration • Event Registration is the process by which an Event Handler gets registered with an Event Listener so that the handler is called when the Event Listener fires the event.
  • 23. Event Handlers • When an event happens and we have registered an event listener for the event, the event listener calls the Event Handlers, which is the method that actually handles the event.
  • 24. Design By Md Shakib Hasan Daffodil International University