From the course: Android Development Essential Training: Your First App with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Display an image in an activity

Display an image in an activity - Android Tutorial

From the course: Android Development Essential Training: Your First App with Kotlin

Start my 1-month free trial

Display an image in an activity

- Android supports the use of images in a variety of formats. You can use traditional web-based formats such as PNG or JPG files. But there's some better formats that are either smaller than those traditional files or are vector graphics that adjust elegantly to different screen sizes and pixel densities. To demonstrate the use of images, I'll start in my content main.xml file. This is the nested layout file. I'll change this text view in a couple of ways. First of all, I'm going to add a unique ID. Every view component that you want to refer to programmatically or within the layout file needs this unique identifier. The ID always starts with '@+id/', and then the ID should be all lowercase. Use underscores if you need to separate any words. I'm going to call this headline. Then I'm going to change this text to my favorite monster. I'll adjust some of these attributes so this is a little bit easier to read. And now I'm ready to display an image. You display images using a component…

Contents