Search code examples
androidlandscape-portraitandroid-7.1-nougat

App won't run in landscape


Today I started trying to optimize my application for landscape mode. But I just cannot get my application to run in landscape mode, there are no settings that I have enabled to force portrait.

I am showing my placeholder screen as an example.

I also double checked that auto rotate in my AVD is enabled. I have this problem on every AVD.

Declared like this in my manifest.

<activity
        android:name=".PlaceholderActivity"
        android:theme="@style/AppTheme.NoActionBar" />

My layout looks like this.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_material_light"
android:orientation="vertical"
android:animateLayoutChanges="true" >

<View
    android:id="@+id/icon"
    android:layout_width="350dp"
    android:layout_height="350dp"
    android:layout_centerInParent="true"
    android:background="@drawable/feedyr_full" />

<ProgressBar
    android:id="@+id/progress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/icon"
    android:layout_centerHorizontal="true"
    android:visibility="visible" />

<include
    layout="@layout/helper_error"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/icon"
    android:layout_centerHorizontal="true" />

</RelativeLayout>

And my Theme looks like this.

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:colorButtonNormal">@color/colorAccent</item>

    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>

    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentStatus">true</item>
</style>

There is also nothing is my class that's forcing portrait

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_placeholder);

    config = FirebaseRemoteConfig.getInstance();
    model = Model.getInstance();
....

My placeholder screen on Nexus 9 running 7.1

What am I missing?


Solution

  • Don't ask me why, but suddenly the landscape mode works. I pressed the screen rotation buttons on the right menu. When it went back in landscape it suddenly worked. Did this before so don't know why it suddenly started to work.

    I did not change anything in my code, theme, manifest or layout...

    AVD in landscape mode