简体   繁体   English

在Android中切换方向

[英]Switching orientation in Android

i have any troubles with switching between orientation from portrait to landscape. 我在从纵向到横向的方向之间切换时遇到了麻烦。

i made this page cause i don't have permission to add images 我做了这个页面因为我没有添加图像的权限

http://www.guitart.comyr.com/ http://www.guitart.comyr.com/

There are my codes and two images. 有我的代码和两个图像。

I've tried to make some small application to test switching, i made same folders as you can see at the page and this small test app works fine. 我试图制作一些小应用程序来测试切换,我创建了相同的文件夹,你可以在页面上看到这个小测试应用程序工作正常。 But my original app doesnt work. 但我原来的应用程序不起作用。

Sorry for English. 对不起英文。

Have you tried to just copy the layout file from layout folder and paste it in "layout-land". 您是否尝试从布局文件夹中复制布局文件并将其粘贴到“layout-land”中。 check the id's of the views because logcat is showing nullPointerException in onCreate. 检查视图的id,因为logcat在onCreate中显示nullPointerException。

Do you have 你有

<Button
   android:id="@+id/btn_menu_info"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignParentRight="true"
   android:layout_alignParentTop="true"
   android:background="@drawable/info64"
   android:src="@drawable/info64" />

in both menu.xml layouts(layout|layout-land) folders? 在两个menu.xml布局(layout | layout-land)文件夹中? If you change the orientation to landscape, your app automatically uses the xmls from your layout-land folder. 如果您将方向更改为横向,则您的应用会自动使用layout-land文件夹中的xmls。 Eclipse don't recognize if the ID exists in both orientations. Eclipse无法识别两个方向中是否存在ID。 Eclipse can't stop you from building because it's no error but it could at least give you a warning imo. Eclipse无法阻止你构建,因为它没有错误,但它至少可以给你一个警告imo。

No problem :) 没问题 :)

<Button
        android:id="@+id/btn_menu_info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/info64"
        android:src="@drawable/info64" />

remove 去掉

android:src="@drawable/info64"

line from this button's property.thats the problem.and you are done. 从这个按钮的property.thats问题。你完成了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android EpoxyRecyclerView - 切换方向 - Android EpoxyRecyclerView - switching orientation 切换方向时保存Android片段的状态 - Saving the state of Android fragment while switching the orientation Android方向传感器-完全关闭方向传感器 - Android orientation sensor - switching off the orientation sensor completely 切换标签页和方向时Android应用程序丢失状态 - Android App Losing State When Switching Tabs And Orientation Android-从纵向/横向切换方向会将属性重置为默认设置 - Android - Switching orientation from portrait/landscape resets attributes to default settings 切换到横向方向很慢 - Switching to landscape orientation is slow Android - 切换到相同方向时调用“onConfigurationChanged()”(即横向反转横向) - Android - “onConfigurationChanged()” not called when switching to same orientation (i.e landscape to reverse landscape)) Android屏幕方向使用不同的xml(切换/旋转屏幕横向和纵向) - Android screen orientation use different xmls (switching/rotating screen landscape and portrait) 使用使用计时器的Android应用程序切换方向时,如何保持原始计时器处于活动状态? - When Switching Orientation with an Android App that uses a Timer, how to I keep the original timer active? 方向android - orientation android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM