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
Jonathan Rios
Courses Plus Student 5,789 PointsBackground not showing
When i run the app i can see and scroll through the hours and everything looks and works just fine. The only thing is the gradient is not showing through. only the grey background. not sure why?
1 Answer
Christopher Augg
21,223 PointsJonathan,
Sorry to here about the background gradient issue you are experiencing. Lets see if we can't find where the issue is located within your project. Unfortunately, without having your code to look over, I will have to give an outline of things to check.
You should have an xml file named bg_gradient.xml located in your drawable folder. It should have the following:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape = "rectangle">
<gradient
android:startColor="#f9d34c"
android:endColor="#f25019"
android:angle="270"
android:type="linear"/>
</shape>
Your activity_main.xml file should use the bg_gradient file like so (only including part of the the xml file):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@drawable/bg_gradient">
activity_daily_forcast.xml and activity_hourly_forecast.xml should follow the activity_main.xml in providing the line needed to associate the gradient:
android:background="@drawable/bg_gradient">
hourly_list_item.xml should use gradient with tools instead like:
tools:background="@drawable/bg_gradient">
daily_list_item.xml does not use gradient:
tools:background="#ffaa00">
Please provide your code if everything I have just went over is correct in your project.
Regards,
Chris
Jonathan Rios
Courses Plus Student 5,789 PointsJonathan Rios
Courses Plus Student 5,789 PointsThank You! everything works fine now