android apps, learn android programming, android for beginners, android
PREV Page -Resources Values Strings Tutorial Android For Beginners- Read the Article
Next Tutorial - Create a Simple Android App

The code in these free Android tutorials is java xml which you can code in AIDE (for tablet coding), or Android Studio (for desktop coding) You can create android apps using either of these SDK platforms.

Resources Drawable Tutorial

nameOfApp is the name you gave the app when creating the AppProject

ic_launcher.png is the default icon for the android app; and is placed in the res/drawable-hdpi folder. It will show on the top of the app's first page(top left) as it's icon. The name you give your app will show next to it. The ic_launcher is also the icon used when you create an app using a simple 'template' as we will be doing in our tutorials.

Naming Your App Images
You can name your images anything you want; usually developers name them to match what they represent. Use underscores for spacing: Example: my_photo_image.
The res/drawable folder is where you place your graphics, photos, for your android app. Example, it could be an icon for your app, or photos being displayed within your app. JPG and PNG are most common ones, example, apphoto.png.

For all types of media that can be used, browse to Android Developer guides:
Android Developer Media Formats

Looking at the top of this image we can see we are in the AppProjects folder and the App name is Math. Res is short for resources; the resources folder where you place all your app's images, graphics, and other media types you want in your android app.

The res/drawable-hdpi is the most common place to put your app's images, however, there are other drawable folders as well: drawable-mdpi, drawable-xhdpi, drawable-xxhdpi.

These represent different screen densities on tablets- smartphones. All you do is place your image(s) in the appropriate folder, or one in each folder if you want to have an image for each screen density type.
The android system knows to grab the image which matches the tablet's screen density.

How to Scale Images For The Various Densities

The actual coding for drawable resources is placed in xml files: This code is for adding an image:


This code is for adding an image as your background


Coding The Manifest.xml File
how to code a drawable resource for android apps
If your adding the app's icon or logo; then you must code its name in the application property of the androidmanifest.xml file as shown.
The androidmanifest.xml is in the root of your AppProjects.

If your adding an image (or other media type) to a TextView, ImageView, or Button element then you code the drawable name in that element.

This xml file is at res/layout/mytextview.xml (mytextview.xml can be whatever name you choose). This file is edited often as you add, and change items in your app's textView pages.

When coding the actual image (media) name you don't include the extension. Example myphoto.png, would be coded as myphoto, you don't need to add the .png in the code.

The example codes show how to code images and add them to the textView.

To learn more about drawables:
Developer Guide Drawable Elements

Code Examples: Adding Images To TextView
Use Mouse To Copy Code

This free script provided by
JavaScript Kit

Share This Page

AIDE for creating Android Apps on your tablet or cell phone(android).
Free and Paid - with Free, create java/xml template apps; couple free android lessons. With paid, many lessons included, create template apps, publish your app at markets like Google, Amazon; and get a 'keystore' for your app.
GoTo Aide

ANDROID STUDIO - for creating Android Apps on your desktop computer.
Free to Install and Use
GoTo Android Studio Learn more - Android Studio

The Java XML files we code(example codes) and the Android Apps we create in our Free Tutorials are compatible with Android Studio and AIDE. Just choose Java XML as your Programming Language.

You May Like:
Make Sushi Rolls Taste World Wines Flavours and Aromas