From the course: Android Development Essential Training: 2 User Interface Design
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Load image resources at runtime - Android Tutorial
From the course: Android Development Essential Training: 2 User Interface Design
Load image resources at runtime
- [Instructor] Currently, we're setting the drawable resource in a static way. Every time we run the app, the image will be the same and it doesn't update. But with the imageView component, we can low resources at runtime as well. This will allow for the image to change, based on either a user action or a change in data. Let's update our layout so that we can include some interaction from the user. For this, we'll introduce a new View that we haven't worked with before, the switch. A switch allows the user to choose between two states. Let's bring over the switch from our pallet, we'll drop it inside of our View. And now we need to update the constraints. We'll constraint the top to the bottom of the imageView, and then the other sides to the parent. The first thing we need to do is remove the bottom constraint from our imageView. We'll click on that constraint handle and then we'll delete it. And it goes all the way…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Display image resources5m 10s
-
(Locked)
Load image resources at runtime6m 16s
-
(Locked)
Reduce file size with WebP images4m 26s
-
(Locked)
Use XML-based VectorDrawable images4m 37s
-
(Locked)
Create icons in Android Studio4m 45s
-
(Locked)
Challenge: Load a network image2m 43s
-
(Locked)
Solution: Load a network image1m 48s
-
(Locked)
-
-