Search code examples
javaandroidandroid-layoutandroid-activityandroid-fullscreen

Android app takes only a part of screen


My app for some reason takes just a part of screen.

Simple onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main); 
}    

Slightly more complicated layout:

<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:id="@+id/content_layout" >

    <LinearLayout 
        android:id="@+id/mainLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

    <LinearLayout
        android:id="@+id/func_layout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:background="@drawable/border_right"
        android:orientation="vertical"
        android:paddingLeft="@dimen/function_layout_padding"
        android:paddingRight="@dimen/function_layout_padding" >
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/graph_layout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="#FFF"
        android:alpha="1.0"
        android:layout_weight="5">
    </RelativeLayout>

    </LinearLayout>

</RelativeLayout>

And I got this:

Android app not in fullscreen

I can't see what the trouble is. Thought that there is emulator problem but on real devices it looks the same.


Solution

  • Thanks to @SunitKumarGupta @AnkitBansal and @Maxouille.

    The problem was in Theme.

    What it was:

    <style name="Theme.Transparent" parent="AppBaseTheme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:backgroundDimEnabled">false</item>
    

    Problem item here is windowIsFloating. Removing it solved the issue.