How To Code a Shape Drawable Line, Android Tutorial
Prev Page Coding Android Resource Identifiers(
This Tutorial - First Tutorial of Tutorials III Coding Shape Drawable Lines - Divider

Next Tutorial Coding A WebView


In tutorials III, we will learn additional app functionalities. As with our previous tutorials, we will include the required app code to copy and paste; with detailed explanation of the code and how to implement it into your app.

We have created a new app for each tutorial; and you can do the same.

You can add your own code to our tutorial app to create your own customized app; or use it just for learning purposes, or use the specific codes to copy paste into your existing apps.

All app code is written in java/xml for android; all apps were created on a android tablet with android version 5 using AIDE; and installed on the same android tablet; as well as on a smartphone with android version 6.0.
The code from these tutorials is compatible with android versions 4, 5, 6, 7 and 8. The latest API is 27.

If you have been learning to create android apps with our tutorials; you now have a good understanding of the app building process.

For each of these tutorials in Tutorials III, we will show a photo of the completed app, and then include the code in the Example Code section. Detailed explanation is provided, as well as link to Android Developer for additional reading on the code class and its' implementation.

Novice Programmers

If you are just arriving at this page; and you are not familiar with with creating Android Apps, we suggest you begin with our tutorials: Coding Android App Pages and How To Create a Simple App in Android and also recommended to read the Beginners Article.

From there follow along with each tutorial lesson.


We are using AIDE(the SDK coding environment for android devices), to create these tutorial apps on our tablet with android version 5; using the Java XML programming language.

We are using the AIDE coding editor to code our pages; and then to Create - Build, RUN and INSTALL them on our android device.
AIDE has a free and paid version. As of this year, the paid version of AIDE is about $20 canadian. Once you create your apps code pages, you need to RUN the app to INSTALL it on your tablet or smartphone.

You can also create; RUN your apps using the code in these tutorials, with Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language. Android Studio is free to install and use. Although not as convenient as testing your app on an actual android device; you can test your newly created app in Android Studio using an android emulator.

Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in either AIDE or Android Studio.


You can get the code from this tutorial from our EXAMPLE CODE section on this page.

This is our app Shape Drawable
Android app shape drawable line


Shape drawables can be created for: lines, rectangles, ovals, and rings.

For this app we are going to create a drawable line and add the color white to it and use it as a divider in our app.

You can add as many dividers as you like to your app page; and this is a way to sectionalize your app. Each section can have text or photos, whatever you like. Looking at our app photo you can see we have added text to each of the sectioned areas. We also added the android icon image in our third section.

The line can have whatever color you want, can be any height you want, and you can place it anywhere you like in the view(the screen view).

For additional reading on coding drawables browse to Android Developer
Coding Drawables

Naming Your App Using AIDE

Also read Naming Your Android App
When creating your app, choose: android apps Java/xml template or example app.
To do so; choose Create New Project from the Left menu in AIDE, then select android gradle/java/xml app.
Then type in an App Name and a Package Name.
You can name your app whatever you like; if your using the name as shown in the example code from this page use;

ShapeDrawable as the app name and,
package name as; com.acw.learndrawables in the next line;

Once you have created your app; you cannot change the package name but you can change the app name. To change the app name, just goto the app projects, highlight the app name as it is now; then select Rename. And, change the name in your strings.xml file also, at the app_name string. Save the strings.xml file and reRun your app to see the new name on the app.

The Code

Coded Pages for the app - ShapeDrawable

Because we create our app using a android java/xml template app; most pages we need to code are already created; therefore, we need only remove the code on the page and replace it with the code from this tutorial. The code is at the Example Code section on this page.
Once you paste the code; save the page.

main.xml, this layout page is already created; just copy paste the code from our Example Code section to replace code on page now and save the page.

strings.xml, this page already created for us, just copy paste the code from our Example Code section to replace code on page now and save the page., this page already created for us, and we don't need to edit this page, so just leave it as it is.

AndroidManifest.xml, this page already created for us, and we don't need to edit this page, so just leave it as it is.

my_divider.xml, this page we need to create and put into the res/drawable folder of your app project; first create the drawable folder at res/;as so; res/drawable, then create the page and name it - my_divider.xml, and add the code to it from our Example Code section on this page, and save the page.

When we create our drawable file; my_divider.xml, we must define this page name in the element where you want it. like this:android:background="@drawable/my_divider"

All drawable shapes are coded this way, and the file(my_divider.xml) must be put into the res/drawable folder of your app project. If your app project does not have one then you must create the folder. Once your at the res/ folder in your project just select: create new folder and name it: drawable

You can add the ScrollView element in case your text scrolls out of the physical view's display
To add it, code it as the first element in your layout file; main.xml; and then close the tag at the end of your code.

In your app, use the LinearLayout coded element where ever you want to put a divider line.

EXAMPLE CODE - Code For This Tutorial

JUST USE YOUR MOUSE to copy the code for this tutorial App Name is 'ShapeDrawable - located at AppProjects/ShapeDrawable in AIDE, open the AIDE app, then open App Projects, THEN select the 'ShapeDrawable', app from your files hierachy(left menu); then click on any file from the app, like strings.xml Make sure at top of page, the app name 'ShapeDrawable' is there next to AppProjects like so: AppProjects/ShapeDrawable, then you know you have the proper App.

Once a file is in the editor, you can edit, save it, then RUN your APP, Install, and Open your app.

Make sure you SAVED EACH PAGE, before you RUN your code. SAVE, RUN, INSTALL, OPEN, your ShapeDrawable App. Once it has been installed on your tablet, you can open it Simply by Clicking on the Android little green App Icon,with the wording 'ShapeDrawable' on your tablet. It will be with your other installed apps.

If you make further changes to this App, you need to SAVE, RUN, UPDATE, INSTALL, OPEN the app.

Example Code Shape Drawable Line :
Use Mouse To Copy Paste the 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 simple app and couple free android lessons. With paid all lessons included, develop and RUN unlimited apps, publish your app at markets like Google, Amazon.
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

Java XML
The Coded Pages

Beginners Article
About Our Tutorials
Coding androidmanifest.xml
Coding main.xml
Coding strings.xml
Coding drawables

Java XML
Learning To Code

Create A Simple
Android App

Change App Icon

Add Text and Style

Add Buttons To App

Placing Text in

Change View
Background Color

Change Screen

Add Image to
Activity View

Add Horizontal
Scroll View

Add a Frame Layout

How to Add Themes
To Your App

How To Code
Customized Styles

Code a Toast Message

Coding Resource


Java XML
Adding Functionality

Coding Shape
Drawable - Lines

Coding A WebView

Coding A Timed
Screen Splash

Coding A Gradient

Coding Fragments

Coding A
ListView Fragment

Coding a
Tabbed Fragment

Share Intent
for Text

Share Intent
for Images

Media Player
with Audio

Coding A
Video Player

Localize Your App
World Languages

from the Web

Add Clickable Button
To textView

Image Button with

Linear Layout with
weight attribute

OnClick Displays

Screen Density
Coding Practices


for android tablets

Android Studio
For desktop computers


Code Canyon Paid From $1 Free and Paid From $1


App Distribution
Launching Your Android App
How To Be Successful

Android App Libraries
What are they and how
to implement them

How To Implement

View All Articles

Coding Tools

Android Studio
Course - Paid

Java Programming
Course - Free

Git Hub Course

About Our Images

All images on this page are copyrighted material.
You can use the images included with each tutorial for the purpose of creating your android app. These images are not to be distributed or sold.


How To Add Your Google Key
To Manifest.xml
Web Article

How To Sign Your APK Web Article

Google Developer Console
Create Account Submit Your App
Web Article

Amazon App DRM - APK KEY
Amazon Developer Portal
Create Account - Submit Your App

Google's In-App Billing for App monetization.

Monetizing Your App
How Tos

Follow Us On Twitter