Question

I'm making an android app. My screen is not changing the orientation of the activity. The android version is 2.3.6 on a samsung pocket.

Following the layout screen.

edit: sorry this tag head below was missing because it was the right below line, how you can see the xml missing part.

<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <EditText android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />

    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"
        android:onClick="sendMessage" />

</LinearLayout>

And AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/CustomActionBarTheme">
        <activity
            android:name="com.example.myfirstapp.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:theme="@style/Custom2ActionBarTheme"
            android:name="com.example.myfirstapp.DisplayMessageActivity"
            android:label="@string/title_activity_display_message"
            android:parentActivityName="com.example.myfirstapp.MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.myfirstapp.MainActivity" />
        </activity>
    </application>

</manifest>

I don't know what else to do, I looked for the solution through google but I couldn't find the answer.

Help

Était-ce utile?

La solution

This phone: http://www.samsung.com/hk_en/consumer/mobile/mobile-phones/smartphone/GT-S5300ZKATGY-features

Does it definitely have a sensor to know its been changed in orientation? In your settings is auto-rotate switched off?

I can't see any issue in what you've posted that I know would stop orientation changes working.

Autres conseils

As the other answers mentions - first you need to check if phone has the ability and then check to see that you do not have the setting disabled in Android.

In your app, "layout" folder under "red" - do you have a "layout-land" folder in which you are defining a layout file that specifies the landscape layout.

Create a layout-land directory (under "res" folder) and put the landscape version of your layout XML file in that directory.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top