Search code examples
androidfill-parent

fill_parent is not filling entire screen in LinearLayout


I tried to search for this answer and the closest I got to an answer was to add android:resizable="true", which is deprecated. I apologize if this question has been answered but I couldn't find it if it was.

Anyway, my app is not filling the entire screen. The method I was using was working in android 2.2 but I am now using a 2.3 emulator and it's not working. I am not sure if this is actually the issue or not.

Now to the problem...

I am creating a temperature converter app (yes, it's homework) and the app is not filling the entire screen even though I say fill_parent for the layout_width and height in the LinearLayout. A suggestion I saw was to use a RelativeLayout, which I could do I suppose but it seems like a band-aid, not a solution. Shouldn't this work?

Here is my code:

<?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:gravity="center_vertical"
    android:background="@color/white"
    >

    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Temperature Converter"
        android:textColor="@color/black"
        />

    <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/convertGroup"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <RadioButton android:id="@+id/CtoF"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Celsius to Fahrenheit"
            android:textColor="@color/black"
            />
        <RadioButton android:id="@+id/FtoC"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Fahrenheit to Celsius"
            android:textColor="@color/black"
            />
    </RadioGroup>

    <EditText
        android:id="@+id/tempInput"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:hint="Temperature"
    />

    <TextView  
        android:id="@+id/converted"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:textColor="@color/black"
    />
</LinearLayout>

Here is the result:

enter image description here


Solution

  • Add below code in menifest after application tag

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