SlideShare a Scribd company logo
1 of 20
Download to read offline
Android Graphics
Topics
• Android Graphics
• Drawables
> Using an image saved in your project resources
> Using an XML file that defines the Drawable
properties
• ShapeDrawable
Android Graphics
Android Graphics Support
• Android graphics are powered by
> A custom 2D graphics library
> OpenGL ES 1.0 for high performance 3D graphics.
• The most common 2D graphics APIs can be
found in the drawable package.
• OpenGL APIs are available from the Khronos
OpenGL ES package, plus some Android
OpenGL utilities.
Drawables
What is a Drawable?
• A Drawable is a general abstraction for
"something that can be drawn."
• Drawable class extends to define a variety of
specific kinds of drawable graphics, including
> BitmapDrawable, ShapeDrawable, PictureDrawable,
LayerDrawable, and several more.
• You can also extend these to define your own
custom Drawable objects that behave in unique
ways.
Three ways to define & instantiate
Drawables
• Using an image saved in your project resources
• Using an XML file that defines the Drawable
properties
• Using the normal class constructors.
Drawables:
Using an image saved in
your project resources
Creating from Resource Images
• A simple way to add graphics by referencing an
image file from your project resources.
• Supported file types are
> PNG (preferred), JPG (acceptable) and GIF
(discouraged).
• Preferred technique for application icons, logos,
or other graphics such as those used in a game
• To use an image resource, just add your file to
the res/drawable/ directory of your project
> From there, you can reference it from your code or
your XML layout using a resource ID, which is the file
name without the file type extension
Build an ImageView that uses an image from
drawable resources and add it to the layout
LinearLayout mLinearLayout;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a LinearLayout in which to add the ImageView
mLinearLayout = new LinearLayout(this);
// Instantiate an ImageView and define its properties
ImageView i = new ImageView(this);
i.setImageResource(R.drawable.my_image);
i.setAdjustViewBounds(true); // set the ImageView bounds to match the
// Drawable's dimensions
i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
// Add the ImageView to the layout and set the layout as the content view
mLinearLayout.addView(i);
setContentView(mLinearLayout);
}
Handle your image resource as a Drawable
object
Resources res = mContext.getResources();
Drawable myImage = res.getDrawable(R.drawable.my_image);
Add a resource Drawable to an ImageView in
the XML layout
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="#55ff0000"
android:src="@drawable/my_image"/>
Drawables:
Using XML
Creating from Resource XML
• If there is a Drawable object that you'd like to
create, which is not initially dependent on
variables defined by your application code or
user interaction, then defining the Drawable in
XML is a good option.
• Even if you expect your Drawable to change its
properties during the user's experience with
your application, you should consider defining
the object in XML, as you can always modify
properties once it is instantiated.
Creating from Resource XML
• Once you've defined your Drawable in XML,
save the file in the res/drawable/ directory of
your project.
• Then, retrieve and instantiate the object by
calling Resources.getDrawable(), passing it the
resource ID of your XML file.
XML that defines a TransitionDrawable
• Let's assume below is saved as
res/drawable/expand_collapse.xml.
<transition
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image_expand">
<item android:drawable="@drawable/image_collapse">
</transition>
XML that defines a TransitionDrawable
Resources res = mContext.getResources();
TransitionDrawable transition = (TransitionDrawable)
res.getDrawable(R.drawable.expand_collapse);
ImageView image =
(ImageView) findViewById(R.id.toggle_image);
image.setImageDrawable(transition);
The above code will instantiate the
TransitionDrawable and set it as the content of an
ImageView
ShapeDrawable
ShapeDrawable
• When you want to dynamically draw some two-
dimensional graphics, a ShapeDrawable object
will probably suit your needs.
• With a ShapeDrawable, you can
programmatically draw primitive shapes and
style them in any way imaginable.
Thank you

More Related Content

What's hot

Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Top 11 Mobile App Development Frameworks
Top 11 Mobile App Development FrameworksTop 11 Mobile App Development Frameworks
Top 11 Mobile App Development FrameworksAlbiorix Technology
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-pptSrijib Roy
 
Android resource
Android resourceAndroid resource
Android resourceKrazy Koder
 
Layouts in android
Layouts in androidLayouts in android
Layouts in androidDurai S
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android pptTaha Malampatti
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Androidma-polimi
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application DevelopmentBenny Skogberg
 
Android Development - ConstraintLayout
Android Development - ConstraintLayoutAndroid Development - ConstraintLayout
Android Development - ConstraintLayoutManuel Vicente Vivo
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidzeelpatel0504
 

What's hot (20)

Android UI
Android UIAndroid UI
Android UI
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Top 11 Mobile App Development Frameworks
Top 11 Mobile App Development FrameworksTop 11 Mobile App Development Frameworks
Top 11 Mobile App Development Frameworks
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-ppt
 
Android Button
Android ButtonAndroid Button
Android Button
 
Android resource
Android resourceAndroid resource
Android resource
 
Notification android
Notification androidNotification android
Notification android
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android ppt
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Android
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Android Development - ConstraintLayout
Android Development - ConstraintLayoutAndroid Development - ConstraintLayout
Android Development - ConstraintLayout
 
Fragment
Fragment Fragment
Fragment
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 

Viewers also liked

new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86Droidcon Berlin
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depthChris Simmonds
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android FragmentsSergi Martínez
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating systemSalma Begum
 
android drawable
android drawableandroid drawable
android drawableukayare
 
Android Web app
Android Web app Android Web app
Android Web app Sumit Kumar
 
Android graphics
Android graphicsAndroid graphics
Android graphicsdcshi
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic TutorialSmartmonk
 
Android Vector Drawable
 Android Vector Drawable Android Vector Drawable
Android Vector DrawablePhearum THANN
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkJussi Pohjolainen
 
Android Vector drawable
Android Vector drawableAndroid Vector drawable
Android Vector drawableOleg Osipenko
 
Революционный Android. Ищем замену фрагментам
Революционный Android. Ищем замену фрагментамРеволюционный Android. Ищем замену фрагментам
Революционный Android. Ищем замену фрагментамRambler Android
 
Vector Drawable API. Возможности применения
Vector Drawable API. Возможности примененияVector Drawable API. Возможности применения
Vector Drawable API. Возможности примененияRambler Android
 
Android security
Android securityAndroid security
Android securityKrazy Koder
 
Android Material Design Quick Presentation
Android Material Design Quick PresentationAndroid Material Design Quick Presentation
Android Material Design Quick PresentationDeimantas Brandišauskas
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic GuideAKASH SINGH
 
Material Design
Material Design Material Design
Material Design Arya Padte
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveBin Chen
 
Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Egor Elizarov
 

Viewers also liked (20)

new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 
android drawable
android drawableandroid drawable
android drawable
 
Android Web app
Android Web app Android Web app
Android Web app
 
Android graphics
Android graphicsAndroid graphics
Android graphics
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic Tutorial
 
Android Vector Drawable
 Android Vector Drawable Android Vector Drawable
Android Vector Drawable
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation Framework
 
Android Vector drawable
Android Vector drawableAndroid Vector drawable
Android Vector drawable
 
Революционный Android. Ищем замену фрагментам
Революционный Android. Ищем замену фрагментамРеволюционный Android. Ищем замену фрагментам
Революционный Android. Ищем замену фрагментам
 
Vector Drawable API. Возможности применения
Vector Drawable API. Возможности примененияVector Drawable API. Возможности применения
Vector Drawable API. Возможности применения
 
Android security
Android securityAndroid security
Android security
 
Android Material Design Quick Presentation
Android Material Design Quick PresentationAndroid Material Design Quick Presentation
Android Material Design Quick Presentation
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic Guide
 
Material Design
Material Design Material Design
Material Design
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)
 

Similar to Android graphics

Drupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and FlickrDrupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and FlickrBen Shell
 
Android App Development - 04 Views and layouts
Android App Development - 04 Views and layoutsAndroid App Development - 04 Views and layouts
Android App Development - 04 Views and layoutsDiego Grancini
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom ViewsBabar Sanah
 
Developing an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDKDeveloping an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDKLuis Beltran
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objectsallenbailey
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDJordan Open Source Association
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App DevelopmentKetan Raval
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsMotorola Mobility - MOTODEV
 
Create an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdkCreate an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdkLuis Beltran
 
Canvas in html5 - TungVD
Canvas in html5 - TungVDCanvas in html5 - TungVD
Canvas in html5 - TungVDFramgia Vietnam
 
Android app material design from dev's perspective
Android app material design from dev's perspectiveAndroid app material design from dev's perspective
Android app material design from dev's perspectiveDeSmart Agile Software House
 
Building real time image classifiers for mobile apps with azure custom vision
Building real time image classifiers for mobile apps with azure custom visionBuilding real time image classifiers for mobile apps with azure custom vision
Building real time image classifiers for mobile apps with azure custom visionLuis Beltran
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricksShem Magnezi
 

Similar to Android graphics (20)

Glide usage tips
Glide usage tipsGlide usage tips
Glide usage tips
 
Drupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and FlickrDrupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and Flickr
 
Android App Development - 04 Views and layouts
Android App Development - 04 Views and layoutsAndroid App Development - 04 Views and layouts
Android App Development - 04 Views and layouts
 
OpenStack Glance
OpenStack GlanceOpenStack Glance
OpenStack Glance
 
Material Design Android
Material Design AndroidMaterial Design Android
Material Design Android
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom Views
 
Developing an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDKDeveloping an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDK
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
 
Android Materials Design
Android Materials Design Android Materials Design
Android Materials Design
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App Development
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on Tablets
 
Create an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdkCreate an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdk
 
Canvas in html5 - TungVD
Canvas in html5 - TungVDCanvas in html5 - TungVD
Canvas in html5 - TungVD
 
Android Ui
Android UiAndroid Ui
Android Ui
 
Android UI
Android UI Android UI
Android UI
 
Android app material design from dev's perspective
Android app material design from dev's perspectiveAndroid app material design from dev's perspective
Android app material design from dev's perspective
 
Building real time image classifiers for mobile apps with azure custom vision
Building real time image classifiers for mobile apps with azure custom visionBuilding real time image classifiers for mobile apps with azure custom vision
Building real time image classifiers for mobile apps with azure custom vision
 
Graphiti presentation
Graphiti presentationGraphiti presentation
Graphiti presentation
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricks
 

More from Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 
2310 b 17
2310 b 172310 b 17
2310 b 17
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 14
2310 b 142310 b 14
2310 b 14
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
2310 b 10
2310 b 102310 b 10
2310 b 10
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Android graphics

  • 2. Topics • Android Graphics • Drawables > Using an image saved in your project resources > Using an XML file that defines the Drawable properties • ShapeDrawable
  • 4. Android Graphics Support • Android graphics are powered by > A custom 2D graphics library > OpenGL ES 1.0 for high performance 3D graphics. • The most common 2D graphics APIs can be found in the drawable package. • OpenGL APIs are available from the Khronos OpenGL ES package, plus some Android OpenGL utilities.
  • 6. What is a Drawable? • A Drawable is a general abstraction for "something that can be drawn." • Drawable class extends to define a variety of specific kinds of drawable graphics, including > BitmapDrawable, ShapeDrawable, PictureDrawable, LayerDrawable, and several more. • You can also extend these to define your own custom Drawable objects that behave in unique ways.
  • 7. Three ways to define & instantiate Drawables • Using an image saved in your project resources • Using an XML file that defines the Drawable properties • Using the normal class constructors.
  • 8. Drawables: Using an image saved in your project resources
  • 9. Creating from Resource Images • A simple way to add graphics by referencing an image file from your project resources. • Supported file types are > PNG (preferred), JPG (acceptable) and GIF (discouraged). • Preferred technique for application icons, logos, or other graphics such as those used in a game • To use an image resource, just add your file to the res/drawable/ directory of your project > From there, you can reference it from your code or your XML layout using a resource ID, which is the file name without the file type extension
  • 10. Build an ImageView that uses an image from drawable resources and add it to the layout LinearLayout mLinearLayout; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create a LinearLayout in which to add the ImageView mLinearLayout = new LinearLayout(this); // Instantiate an ImageView and define its properties ImageView i = new ImageView(this); i.setImageResource(R.drawable.my_image); i.setAdjustViewBounds(true); // set the ImageView bounds to match the // Drawable's dimensions i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); // Add the ImageView to the layout and set the layout as the content view mLinearLayout.addView(i); setContentView(mLinearLayout); }
  • 11. Handle your image resource as a Drawable object Resources res = mContext.getResources(); Drawable myImage = res.getDrawable(R.drawable.my_image);
  • 12. Add a resource Drawable to an ImageView in the XML layout <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#55ff0000" android:src="@drawable/my_image"/>
  • 14. Creating from Resource XML • If there is a Drawable object that you'd like to create, which is not initially dependent on variables defined by your application code or user interaction, then defining the Drawable in XML is a good option. • Even if you expect your Drawable to change its properties during the user's experience with your application, you should consider defining the object in XML, as you can always modify properties once it is instantiated.
  • 15. Creating from Resource XML • Once you've defined your Drawable in XML, save the file in the res/drawable/ directory of your project. • Then, retrieve and instantiate the object by calling Resources.getDrawable(), passing it the resource ID of your XML file.
  • 16. XML that defines a TransitionDrawable • Let's assume below is saved as res/drawable/expand_collapse.xml. <transition xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image_expand"> <item android:drawable="@drawable/image_collapse"> </transition>
  • 17. XML that defines a TransitionDrawable Resources res = mContext.getResources(); TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.expand_collapse); ImageView image = (ImageView) findViewById(R.id.toggle_image); image.setImageDrawable(transition); The above code will instantiate the TransitionDrawable and set it as the content of an ImageView
  • 19. ShapeDrawable • When you want to dynamically draw some two- dimensional graphics, a ShapeDrawable object will probably suit your needs. • With a ShapeDrawable, you can programmatically draw primitive shapes and style them in any way imaginable.