2014-01-30 48 views
0

我正在製作一個android應用程序。我的屏幕沒有改變活動的方向。三星口袋裏的android版本是2.3.6。android方向不起作用

按照佈局屏幕。

編輯:對不起,這下面的標籤頭失蹤,因爲它是正確的下線,你如何看到XML缺失的部分。

<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> 

而且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> 

我不知道自己能做什麼,我找了通過谷歌的解決方案,但我無法找到答案。

幫助

+2

手機上的其他應用程序是否可以旋轉?也許你在手機的設置中禁用了自動旋轉功能。 – NasaGeek

+0

有一個詳細信息.. android:方向正在對Android 4.0執行模擬的模擬器上工作。也許是一些兼容性問題,不是嗎? – ThiagoCoder

回答

2

此電話:http://www.samsung.com/hk_en/consumer/mobile/mobile-phones/smartphone/GT-S5300ZKATGY-features

是否肯定有一個傳感器,知道它的方向已經改變?在您的設置是自動旋轉關閉?

我不能在您發佈的內容中看到任何問題,我知道這會阻止方向更改正常工作。

+0

嗨,尼克,謝謝你的回答。我的手機有一個傳感器來改變方向。我知道,因爲我還有其他的功能,我從谷歌玩這個funcionality。我的文件夾佈局位於文件夾res中。你提到的手機圖片是我擁有的。 – ThiagoCoder

+1

非常感謝你!這是一個小白癡的問題...我的設置自動旋轉已關閉...也許其他應用程序正在我的手機上進行旋轉是因爲他們正在做這個以編程方式,以防用戶關閉像我一樣! – ThiagoCoder

1

正如其他人提到的答案 - 首先你需要檢查手機是否有能力,然後檢查看看你沒有在Android中禁用該設置。

在您的應用程序中,「紅色」下的「佈局」文件夾 - 您是否有一個「layout-land」文件夾,您在其中定義了指定橫向佈局的佈局文件。

創建一個layout-land目錄(位於「res」文件夾下)並將佈局XML文件的橫向版本放在該目錄中。

+0

這個答案提出了一個很好的方法來檢查問題,但(不知道如果你知道user1406716),景觀不是必需的,它只是一種方法來優化 –

+0

嗨。我沒有res下的文件夾佈局,只是包含上述xml的文件夾佈局。 – ThiagoCoder

+0

我相信你是正確的尼克卡多佐,因爲我沒有看到有必要提到有必要這樣做的定位作品。 – ThiagoCoder