简体   繁体   中英

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应用未全屏显示

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

Okay so try this :

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

    setContentView(R.layout.activity_main); 
} 

You do not need that below because it will create this kind of windows.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM