SlideShare a Scribd company logo
Developing Efficient Android UI
Adapters in Android An Adapter object acts as a bridge between an View and the underlying data for that view. One side of the adapter is a data structure like a Java object storing data. the other side of the adapter, there is  view that the data structure was transformed into.   The Adapter is also responsible for making a View for each item in the data set .
 
Considering Adaptor for the List View Each List item in the List View would be calling its “ getView() ” method. This method would return a view for the List. But creating a new View for each list item would be complicated, and the UI would be slow down. Instead of creating new View for each item, Recycler save these view and passes it to the Adapter. Adapter uses these view sent by the recycler, when it has to produce any new views.
View Holders View Holders hold some data that related to an item to the view. View Holders minimizes the amount of work, while writing the same piece of code again and again. These are used while creating the views, where we have to use more than one time. (TextView)findViewById(R.Id.text); (ImageView)findViewById(R.Id.Icon); By using the View Holders, the views are saved into a class variable and can be called when needed. holder.text = (TextView)findViewById(R.id.text); holder.icon = (ImageView)findViewById(R.id.icon); convertView.setTag(holder); A tag can hold any kind of object, that can be set on the view.
 
Backgrounds Backgrounds can be any bitmap images or Colors or any resource from drawable directory. The background will completely fills the view. Scaling a bitmap at runtime would be difficult as it has to fill the complete view. Instead  pre-scale  the bitmap and then set it as background. Else use the solid colors as background to fill the view. This would increase the frame rate 50 frames per sec. (In normal we have 25 frames per sec).
Pre-scaling a bitmap Bitmap.createScaledBitmap( originalImage,  //bitmap to resize view.getwidth()  //new width view.getHeight() //new Height true); //bi-linear filterring
Drawing and Invalidating Invalidate is a method used to redraw Using invalidate method the entire screen is redrawn again. This may consume some time to return to the normal state. While invalidating two areas on the screen (say, top right and bottom left of the screen) the frame work would take the union of the area and redraws. Solution for these problems would be: invalidate(Rect)  and  invalidate(left, top, right, bottom) Frames would be increased to 50 per sec. (normally 18 frames)
Views and Layouts View is a basic building block of the user interface component. A view occupies a rectangle area on the screen and is responsible for drawing and event handling. UI containing many Views would make the application to run slower as it has to load every view accordingly. Drawing of objects on many views is a difficult task and requires more time to start an activity. This may cause  stackOverflow  Exception (as the stack size in android is 8kb). Deep hierarchies makes the UI very slow.
Compound Drawables <Linearlayout android:orientation = “horizantal” android:layout_width = “fill_parent” android:layout_height = “wrap_content” />   <TextView  android:layout_width = “wrap_content” android:layout_height = “wrap_content android:text = “@string/hello” /> <ImageView android:layout_width = “wrap_content” android:layout_height = “wrap_content” android:src = “@drawable/icon” /> </Linearlayout> The above code can be written as: <TextView android:layout_width = “wrap_content” android:layout_height = “wrap_content” android:text = “@string/hello” android:drawableLeft = “@drawable/icon” />
View Stub in android View Stub  is a dumb and lightweight view. It has no dimensions and does not participate in Layouts. View Stud is a feature that allows  runtime inflation  of views. <ViewStub   android:id=“@+id/stub”   android:inflateId=“@+id/panel_import”   android:lalyout = “@layout/progress_overlay”   android:gravity = “bottom” /> Inflating a View Stub…. findViewById(R.id.stub).setVisibility(View.VISIBLE); or View importPannel = ((ViewStub)findViewById(R.id.stub)).inflate();
Merge The <merge /> can only be the root tag in the xml file. This tag would reduces the levels of hierarchies in the xml layout file. <merge xlms:android=“”> <!– content -->  </merge>
Relative Layout Relative layout are powerful layout in android. Relative layout replaces the Linear layout as the widgets are placed in either horizontal or vertical way. Each child element is laid out in relation to other child elements. Relationships can be established so that children will start themselves where a previous child ends. Children can relate only to elements that are listed before them.
Custom Views Custom Views are very simple to use. Just need to override only two methods. onDraw(Canvas canvas)  onMeasure(int Width, int height)  We can define the dimensions of the view.
Custom Layouts Custom Layouts are used to define user defined layouts instead of using the pre-defined layouts. Using custom layout, user can define: height and width of the layout Childs residing on the layout Visibility of the children during runtime. To define custom layout, A class should extend  ViewGroup override  onMeasure  and  onLayout  methods.

More Related Content

PDF
Android UI System
PPTX
Android Layout
PDF
Basic Android Layout
PDF
Adapter and cache technique
PPTX
Android Training (Android UI)
PPTX
Android android layouts
PDF
Android Screen Containers & Layouts
PDF
Advance Android Layout Walkthrough
Android UI System
Android Layout
Basic Android Layout
Adapter and cache technique
Android Training (Android UI)
Android android layouts
Android Screen Containers & Layouts
Advance Android Layout Walkthrough

What's hot (20)

PPTX
Material Design Android
PDF
01 09 - graphical user interface - basic widgets
PDF
Best Practices for Android UI by RapidValue Solutions
PDF
Listview and Adapter
PPTX
Android ui with xml
PPTX
Android Widget
PDF
Chapter 5 - Layouts
PDF
Android Material Design APIs/Tips
PDF
Android app material design from dev's perspective
PDF
Android Lollipop and Material Design
PDF
Android Lollipop - Webinar vom 11.12.2014
PPTX
Building a simple user interface lesson2
PDF
Material design basics
PPTX
What’s new for Android Developers in 2015 - Material Design, Android Studio, ...
PPTX
Create an android app for database creation using.pptx
PDF
Android appwidget
PDF
Training Session 2
PDF
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
PPTX
Android Tutorials - Powering with Selection Widget
PPTX
Android Tutorials : Basic widgets
Material Design Android
01 09 - graphical user interface - basic widgets
Best Practices for Android UI by RapidValue Solutions
Listview and Adapter
Android ui with xml
Android Widget
Chapter 5 - Layouts
Android Material Design APIs/Tips
Android app material design from dev's perspective
Android Lollipop and Material Design
Android Lollipop - Webinar vom 11.12.2014
Building a simple user interface lesson2
Material design basics
What’s new for Android Developers in 2015 - Material Design, Android Studio, ...
Create an android app for database creation using.pptx
Android appwidget
Training Session 2
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
Android Tutorials - Powering with Selection Widget
Android Tutorials : Basic widgets
Ad

Viewers also liked (20)

PDF
Layouts in android
PDF
Android ui layout
PPT
android layouts
PDF
Input and Output Control
PPT
PDF
Make Recyclerview With Android Studio
DOC
PDF
Android networking in Hindi
PDF
Learn java in hindi
PDF
Inside Android's UI
PDF
Android Lesson 2
PPTX
Android ppt
PDF
Intent in android
PDF
Android intents
PDF
Android: Intent, Intent Filter, Broadcast Receivers
PPT
Android ppt
PDF
Effective Android UI - English
PPTX
Final year project presentation in android application
PPTX
Android ppt
ZIP
Android Application Development
Layouts in android
Android ui layout
android layouts
Input and Output Control
Make Recyclerview With Android Studio
Android networking in Hindi
Learn java in hindi
Inside Android's UI
Android Lesson 2
Android ppt
Intent in android
Android intents
Android: Intent, Intent Filter, Broadcast Receivers
Android ppt
Effective Android UI - English
Final year project presentation in android application
Android ppt
Android Application Development
Ad

Similar to Android Ui (20)

PPT
Hello Android
PPT
View groups containers
PPTX
Unit 2 part for information technology1 4.pptx
PPTX
Adapter and adapter views that are used in android
PPTX
06. Android Basic Widget and Container
PDF
04 user interfaces
PPTX
INTRODUCTION AND BASICS OF Android NOTES.pptx
PDF
How to use data binding in android
PDF
MVVM & Data Binding Library
PPT
Android | Busy Java Developers Guide to Android: UI | Ted Neward
PDF
Fragments: Why, How, What For?
DOCX
Android xml-based layouts-chapter5
DOCX
How to create ui using droid draw
PPTX
chp 4 UI component hdjdjdduudfinalt.pptx
PDF
07_UIAndroid.pdf
PPT
Beginning Native Android Apps
PPT
Android Tutorial
ODP
Android App Development - 04 Views and layouts
PPTX
Lecture 2 Styling and Layout in React Native.pptx
PDF
Mobile Application Development -Lecture 07 & 08.pdf
Hello Android
View groups containers
Unit 2 part for information technology1 4.pptx
Adapter and adapter views that are used in android
06. Android Basic Widget and Container
04 user interfaces
INTRODUCTION AND BASICS OF Android NOTES.pptx
How to use data binding in android
MVVM & Data Binding Library
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Fragments: Why, How, What For?
Android xml-based layouts-chapter5
How to create ui using droid draw
chp 4 UI component hdjdjdduudfinalt.pptx
07_UIAndroid.pdf
Beginning Native Android Apps
Android Tutorial
Android App Development - 04 Views and layouts
Lecture 2 Styling and Layout in React Native.pptx
Mobile Application Development -Lecture 07 & 08.pdf

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PPTX
1. Introduction to Computer Programming.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Network Security Unit 5.pdf for BCA BBA.
Tartificialntelligence_presentation.pptx
Group 1 Presentation -Planning and Decision Making .pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Getting Started with Data Integration: FME Form 101
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
1. Introduction to Computer Programming.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation_ Review paper, used for researhc scholars
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
A comparative analysis of optical character recognition models for extracting...
Encapsulation theory and applications.pdf

Android Ui

  • 2. Adapters in Android An Adapter object acts as a bridge between an View and the underlying data for that view. One side of the adapter is a data structure like a Java object storing data. the other side of the adapter, there is view that the data structure was transformed into. The Adapter is also responsible for making a View for each item in the data set .
  • 3.  
  • 4. Considering Adaptor for the List View Each List item in the List View would be calling its “ getView() ” method. This method would return a view for the List. But creating a new View for each list item would be complicated, and the UI would be slow down. Instead of creating new View for each item, Recycler save these view and passes it to the Adapter. Adapter uses these view sent by the recycler, when it has to produce any new views.
  • 5. View Holders View Holders hold some data that related to an item to the view. View Holders minimizes the amount of work, while writing the same piece of code again and again. These are used while creating the views, where we have to use more than one time. (TextView)findViewById(R.Id.text); (ImageView)findViewById(R.Id.Icon); By using the View Holders, the views are saved into a class variable and can be called when needed. holder.text = (TextView)findViewById(R.id.text); holder.icon = (ImageView)findViewById(R.id.icon); convertView.setTag(holder); A tag can hold any kind of object, that can be set on the view.
  • 6.  
  • 7. Backgrounds Backgrounds can be any bitmap images or Colors or any resource from drawable directory. The background will completely fills the view. Scaling a bitmap at runtime would be difficult as it has to fill the complete view. Instead pre-scale the bitmap and then set it as background. Else use the solid colors as background to fill the view. This would increase the frame rate 50 frames per sec. (In normal we have 25 frames per sec).
  • 8. Pre-scaling a bitmap Bitmap.createScaledBitmap( originalImage, //bitmap to resize view.getwidth() //new width view.getHeight() //new Height true); //bi-linear filterring
  • 9. Drawing and Invalidating Invalidate is a method used to redraw Using invalidate method the entire screen is redrawn again. This may consume some time to return to the normal state. While invalidating two areas on the screen (say, top right and bottom left of the screen) the frame work would take the union of the area and redraws. Solution for these problems would be: invalidate(Rect) and invalidate(left, top, right, bottom) Frames would be increased to 50 per sec. (normally 18 frames)
  • 10. Views and Layouts View is a basic building block of the user interface component. A view occupies a rectangle area on the screen and is responsible for drawing and event handling. UI containing many Views would make the application to run slower as it has to load every view accordingly. Drawing of objects on many views is a difficult task and requires more time to start an activity. This may cause stackOverflow Exception (as the stack size in android is 8kb). Deep hierarchies makes the UI very slow.
  • 11. Compound Drawables <Linearlayout android:orientation = “horizantal” android:layout_width = “fill_parent” android:layout_height = “wrap_content” /> <TextView android:layout_width = “wrap_content” android:layout_height = “wrap_content android:text = “@string/hello” /> <ImageView android:layout_width = “wrap_content” android:layout_height = “wrap_content” android:src = “@drawable/icon” /> </Linearlayout> The above code can be written as: <TextView android:layout_width = “wrap_content” android:layout_height = “wrap_content” android:text = “@string/hello” android:drawableLeft = “@drawable/icon” />
  • 12. View Stub in android View Stub is a dumb and lightweight view. It has no dimensions and does not participate in Layouts. View Stud is a feature that allows runtime inflation of views. <ViewStub android:id=“@+id/stub” android:inflateId=“@+id/panel_import” android:lalyout = “@layout/progress_overlay” android:gravity = “bottom” /> Inflating a View Stub…. findViewById(R.id.stub).setVisibility(View.VISIBLE); or View importPannel = ((ViewStub)findViewById(R.id.stub)).inflate();
  • 13. Merge The <merge /> can only be the root tag in the xml file. This tag would reduces the levels of hierarchies in the xml layout file. <merge xlms:android=“”> <!– content --> </merge>
  • 14. Relative Layout Relative layout are powerful layout in android. Relative layout replaces the Linear layout as the widgets are placed in either horizontal or vertical way. Each child element is laid out in relation to other child elements. Relationships can be established so that children will start themselves where a previous child ends. Children can relate only to elements that are listed before them.
  • 15. Custom Views Custom Views are very simple to use. Just need to override only two methods. onDraw(Canvas canvas) onMeasure(int Width, int height) We can define the dimensions of the view.
  • 16. Custom Layouts Custom Layouts are used to define user defined layouts instead of using the pre-defined layouts. Using custom layout, user can define: height and width of the layout Childs residing on the layout Visibility of the children during runtime. To define custom layout, A class should extend ViewGroup override onMeasure and onLayout methods.