user3078406
user3078406

Reputation: 511

Landscape Layout xml does not rotate content

In Eclipse-Android; I created two xml files; one for portrait and one for landscape. In a tutorial, the instructor simply added the same xml portrait content to a landscape xml file and when the application ran the view was correctly displayed in both portrait and landscape modes. However, I tried doing the same thing with a list view but the list view does not rotate to landscape. I have set the orientation to horizontal with android:orientation="horizontal" and in the graphical layout I can see the content in landscape, but when the application runs the portrait list view content does not rotate to landscape. What could I be doing wrong?

Here is the xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".Activity" >

<TextView
    android:id="@android:id/empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="@string/no_data" /> <!-- Will display when There is no data. Need to Add Name/Value to xml value string.xml file as well -->

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:orientation="horizontal" >
</ListView>

Upvotes: 0

Views: 268

Answers (1)

Baker
Baker

Reputation: 28010

This is likely an issue with the emulator, not your code.

https://code.google.com/p/android/issues/detail?id=61671

Google just released (10 days ago, March 12, 2015) an update to their Android SDK (API 22) which apparently fixes this issue (where you rotate emulator screen, but it stays in portrait mode).

The immediate fix would be to use a different target SDK API level for your emulator.

In Eclipse menu, Window -> Android Virtual Device Manager.

Edit an existing emulator (or create a new one) using a Target other than API 19.

API 18 works OK. I assume API level 22 (the fixed version according to Google, in the above link) work would as well.

When you Ctrl + F11 (Ctrl + fn + F11 on Mac), the emulator should rotate and so should your app user interface.

Upvotes: 1

Related Questions