Time for action - drawing a broken line

All of the shapes defined in Android allow you to use the<stroke> element to define a dotted or dashed line structure, but it's really best shown-off on the line element. If we increase the width of the line and define a dash pattern with dash segments double the size of the spacing, we get a line that looks much like a "cut" or "tear" line on a printed page. This is a great way to make harder separators on a user-interface.

  1. Create a new shape resource XML file in the res/drawable directory named line.xml and open this file in an editor or IDE.
  2. Declare the root element of the file as a line shape:
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    
  3. Declare a stroke element ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.