2014-01-30 51 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