Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (retired 2014) Pretty Little Things Adding an Image

I followed everything to the letter, error.

I followed everything, but when I changed the order of views (dragged img to the top) my app crashes, it only works when it is the last one

1 Answer

Matheus G Oliveira
Matheus G Oliveira
9,682 Points

if you want to add a background image, it is simple.

add this to the activity.xml you want to add a background image. PS.: dont forget to drag and drop the image to the drawable file on res directory.

         android:background="@drawable/your_image_name" 

the code below goes inside of the relative layout where you have something like these: EXample: xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="fill"