Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Fullscreen

I've never been able to get anything (images & buttons so far) to go actual full screen and touch the edge of the display, it always stops just a little before the edge... Is this a common problem? Or am I missing something?

2 Answers

Hey Jace Galloway this is mostly because Android (recently) started to implement a default padding on the layouts in your .xml files.

For example, if you create a brand new application in Android you will get a layout that will look like this:

<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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

You can see that inside of the RelativeLayout it has:

    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

which basically tells Android to go and look in res > values > dimens.xml. If you navigate to that file and open up the .xml you will see it contains:

<resources>

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>

</resources>

Bam! That is where you default padding is coming from. As you can see, it gives you the defaults, per the Android Design Guidelines. Try changing the numbers in the dimens.xml file and you will see it update in your layout. Pretty cool!

Learn more about Android design here: http://developer.android.com/design/index.html

Once again, thank you for your invaluable help!

Stefan Bols
Stefan Bols
2,515 Points

Exactly my problem - thanks!

Anthony Hind
Anthony Hind
5,715 Points

sorry didn't see your android tag ...