0

Update

After adding the following style and setting it for my application, I have gotten it draw the whole screen:

<resources>
    <style name="app_theme" parent="android:Theme.NoTitleBar">
        <item name="android:windowBackground">@color/green</item>
    </style>    
</resources> 

While developing my first Android app I've realized that my apps' views never span the entire screen whereas other sample projects I have downloaded do. To test this I have created a basic activity class and set the background of a TextView to green to see how much it is spanning. Forgive me if this is a stupid question but I am new to this.

Here is the screenshot:

enter image description here

Here is the complete HomeActivity Source:

public class HomeActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Here is the layout file (/res/layout/main.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="Hello World, StackOverflow"
    android:background="#00FF00"
    />
</LinearLayout>

and here is a screenshot of another app in the emulator working fine, spanning the whole window:

enter image description here

Edit

I edited my XML file to now be:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00FF00"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="Hello World, StackOverflow"
    />
</LinearLayout>

Then cleaned and built, ran and got the same exact view.

Edit 2

I removed the "vertical" orientation line as requested, no change.

Here is my AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.blah.blah.myCrap"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <application android:label="@string/app_name" >
        <activity android:name="HomeActivity"
                  android:label="@string/app_name">
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest> 

Added the following to my manifest under <application>

<supports-screens android:resizeable="true"
                      android:smallScreens="true" 
                      android:normalScreens="true" 
                      android:largeScreens="true"

                      android:anyDensity="true" />

Still the wrong size.

tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126

2 Answers2

1

It's coming fine on Android 2.2 emulator

enter image description here

Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36
1

Check your manifest to see if it supports different screen sizes. You can find more information in this QA ( fill_parent is not filling entire screen in LinearLayout )

Apparently, if you don't specify that it supports small, normal, large, anydensity screen sizes, you can have issues with layouts not filling the entire screen.

Community
  • 1
  • 1
Gophermofur
  • 2,101
  • 1
  • 14
  • 14
  • I had high hopes for this one... but it did not work. Added the code for `support-screens` as referenced, clean + build, run, same result. – tacos_tacos_tacos May 11 '12 at 18:53