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 trialNiravkumar Patel
2,277 PointsNameSpace tools vs android
I had put relative layout's background as this
tools:background="@android:color/holo_blue_light"
It but it didnt work, I changed tools name space with android and it worked What is the difference between them I had added tools namespace tag to in relative layout. Here is my relative layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
//this worked android:background="@android:color/holo_blue_light"
//this didnt work tools:background="@android:color/holo_blue_light"
tools:context="com.example.aalap.funfactkotlin.MainActivity">
1 Answer
Seth Kroger
56,413 PointsThe 'tools' namespace will set the value for Android Studio's preview but not the actual app. This is useful when you need placeholders to help you see what the layout will be like. If your app, say, displayed data from an API over the internet it's useful to have placeholder text than blank text to see the layout, but you don't want the placeholder text in the app.
Niravkumar Patel
2,277 PointsNiravkumar Patel
2,277 Pointsgreat, makes sense. Thank you Seth.