O'Reilly logo

Android UI Design by Jessica Thornsby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating views

Views are the basic building blocks of a user interface.

Most of the time you'll create view objects by adding them to your Activity's corresponding layout resource file. You can either edit the XML code directly, or you may want to drag UI elements from your IDE's palette and drop them onto the UI preview:

Creating views

You also have the option of creating views programmatically. For example, if you wanted to instantiate a TextView programmatically, you would add TextView to your Activity's onCreate() method:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required