我正在使用JQUery Mobile Beta 1编写移动应用程序,并期望屏幕在从纵向旋转到横向时自动调整iphone,反之亦然,但它没有发生.
我只是打开了这个链接(Beta 1 doc demo)
http://jquerymobile.com/demos/1.0b1/docs/pages/page-template.html
但它也没有调整屏幕.
我错过了什么吗?
编辑:Beta 2似乎相同.我检查了演示和文档iPhone,它的行为类似.我需要点按一个屏幕进行调整.不像纵向那样自动进行.
Itizme
我正在尝试使用样式设置活动屏幕方向:
这是styles.xml:
...
<style name="Some.Activity" parent="android:Theme">
<item name="android:screenOrientation">portrait</item>
</style>
...
Run Code Online (Sandbox Code Playgroud)
这是AndroidManifest.xml中的活动声明:
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"/>
Run Code Online (Sandbox Code Playgroud)
它不起作用.
我知道我可以设置
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"
android:screenOrientation="..."/>
Run Code Online (Sandbox Code Playgroud)
在清单中,但使用主题对我来说很重要.
想法?
我已经设法在我的活动中更改了片段的方向.旋转设备时,方向会发生变化.
现在,当我点击片段中的按钮时,我想要相同的功能.即当我点击肖像布局和签证上的按钮时,我想从纵向模式更改为LandScape模式.
我用了
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Run Code Online (Sandbox Code Playgroud)
和
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Run Code Online (Sandbox Code Playgroud)
分别.
但这使自动旋转功能停止工作.我该如何解决这个问题?
android screen-orientation orientation-changes android-fragments
由于历史原因,我在下面保留原始问题.但是,我发现这个问题并不孤立FrameLayout.因此,更新了标题.
我没有用更多的代码过度拥挤这篇文章,而是创建了一个示例项目来演示这个问题; 并将其上传到Google Project Hosting.
问题的摘要是这样的:
纵向可绘制,其上设置有特定边界,在改变方向并返回纵向时,不保留设定边界.相反,它恢复到原来的界限.尽管有力地设定了方向变化的明确界限.请注意,您遵守以后在Click等上设置的任何边界都会被遵守.
我还上传了一个版本的应用程序,其中包含2个单独的活动来说明问题.
BitmapDrawable上ImageView-这一个打印边界时被更改日志.第二个版本清楚地表明,即使我在Drawable上设置了边界,这些边界也没有被遵守onBoundsChange().
原始问题:
我使用的是FrameLayout具有2个ImageView小号一个堆叠在另一个用于显示"电池状态"的图形的顶部.这是纵向模式.在横向模式下,我显示不同的布局(图表).
我的问题是这个 - 假设电池状态正在显示 - 比如说30%.现在,我旋转屏幕并显示图表.当我回到纵向方向时,电池图形将返回其原始位置("已满").
我尝试了各种各样的事情来弄清楚发生了什么.调试向我显示"顶部"图形的边界确实按预期设置.所以这似乎是一个无效的问题.我将介绍2个类和2个布局XML(全部简化)的代码,这有助于重现问题.还附加用于ImageView的占位符PNG.

谁能发现错误?要重新创建该问题,请运行该应用程序,然后单击"更新"按钮.图形将被"填充"到一定水平.然后,切换到横向,然后返回到肖像.图形不记得它的早期值.
活动:
public class RotateActivity extends Activity {
private View portraitView, landscapeView;
private LayoutInflater li;
private Configuration mConfig;
private ValueIndicator indicator;
private Button btn;
private Random random = new java.util.Random();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
li = LayoutInflater.from(this);
portraitView = …Run Code Online (Sandbox Code Playgroud) android invalidation screen-orientation android-imageview android-framelayout
我的Android应用程序中有一个相当简单的登录页面,包含标题,用户名TextView,密码TextView,登录按钮和图像页脚:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<!-- Header Starts -->
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<!-- Logo Start -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:src="@drawable/header" />
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:layout_alignParentBottom="true"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:src="@drawable/footer" />
</LinearLayout>
<!-- Footer Ends -->
<!-- Login Form -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip"
android:layout_below="@+id/header"
>
<!-- Application Name …Run Code Online (Sandbox Code Playgroud) android screen screen-orientation android-layout android-softkeyboard
使用setFrame重绘帧后,我的变换不会绘制.
我在使用setFrame更改方向时缩放视图.但是这个视图还需要根据BOOL参数改变位置:On = up in view,off = down off screen.我setTransform用来调整视图的位置.
首先,我通过做一个绘制视图setFrame.这会在底部的屏幕上绘制100点视图.然后我设置一个变换(ty上的-100)将它带到视点(只要BOOL设置为TRUE,否则变换为0,视图不在屏幕上).
[view setFrame:CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 100)];
[view setTransform:CGAffineTransformMake(1, 0, 0, 1, 0, -100)]
Run Code Online (Sandbox Code Playgroud)
这正常,正如预期的那样,但是当更改方向,并且重新运行此代码(重新调整视图大小)时,即使将Logged视为视图的变换,也不会绘制变换.换句话说,视图就在屏幕外,就像transform.ty为0一样.
Log message before re-draw: view.transform.ty -10.000000
Log message after re-draw: view.transform.ty -10.000000
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
我在这里遇到一点问题.我在同一个故事板上有两个视图控制器(MainStoryboard - >纵向模式下的Calc视图控制器和横向模式下的Calc视图控制器).当我最初创建一个boolfor shouldAutoRotate它确实旋转然而"仍然是"一个渲染问题,因为一些按钮等不在你期望它们的位置,换句话说它们在横向模式中都到处都是.所以现在我在横向模式和主肖像模式下创建了2个视图控制器.所以现在关键是在旋转时在这两个控制器之间切换.
在CalculatorViewController.mi中有
UPDATE
我注意到一些方法从iOS 6中删除了(那就是我现在使用的那个)经过一些研究我发现在iOS 6中"有点正确的方法"就是这个
@synthesize portraitView, landscapeView;
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations:toInterfaceOrientation
{
if(UIInterfaceOrientationMaskAllButUpsideDown)
{
if ( UIInterfaceOrientationPortrait )
{
self.view = portraitView;
}
else if ( UIInterfaceOrientationLandscapeLeft )
{
self.view = landscapeView;
}
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
然而,虽然我认为我使用的是关于iOS 6的正确方法,但仍然无法在旋转时调用正确的视图控制器
并在CalculatorViewController.h中
@interface CalculatorViewController : UIViewController {
IBOutlet UIView *portraitView; // declaring view - portrait
IBOutlet UIView *landscapeView; // declaring view - landscape
//rest of irrelevant code below
}
@property (nonatomic, retain) …Run Code Online (Sandbox Code Playgroud) objective-c interface-builder uiviewcontroller screen-orientation ios
我正在使用openGL ES创建一个Android应用程序,我有以下问题:
当我最小化应用程序,然后重新打开它时,在我的GLSurfaceView.Renderer中的onSurfaceChanged被调用2次.
我在onSurfaceChanged中有以下代码(和onSurfaceCreated,onDrawFrame中的类似代码):
Log.e("onSurfaceChanged",Integer.toString(width)+" "+Integer.toString(height));
Run Code Online (Sandbox Code Playgroud)
所以我得到以下日志:
onSurfaceCreated onSurfaceChanged 480 800 onDrawFrame onSurfaceChanged 480 800 onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame (...)
当我最小化时,将屏幕方向从纵向更改为横向,然后重新打开,onSurfaceChanged被调用3次.日志是:
onSurfaceCreated onSurfaceChanged 480 800 onDrawFrame onSurfaceChanged 480 800 onDrawFrame onDrawFrame onDrawFrame onSurfaceChanged 800 480 onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame (...)
我的问题:这是一个错误吗?在我的应用程序中还是Android错误?有一种方法可以在onSurfaceChanged上调用一次吗?(因为在onSurfaceCreated中我正在执行减慢应用程序的代码)
提前致谢
在我看来,这在iOS9中不再起作用了.这是根据我的SO研究强制改变方向的事实上的方法.它现在冻结了我的SpriteKit游戏.
它只是我,如果没有,是否有人知道另一种选择?
编辑:肖像和UpsideDown仍然有效.似乎只有Landscape模式现在导致冻结
编辑2:其实我认为你可以去肖像< - > UpsideDown和LandscapeLeft < - > LandscapeRight,但不能介于他们之间
我应该创建不同的布局文件夹来存储我的xml布局文件.在不同的屏幕尺寸上支持我的应用程序?
我开发了一个应用程序,当添加drawable时,它会自动创建不同的大小,如xdpi ldpi和更多,但不会自动创建布局xml文件以支持不同的屏幕尺寸.我应该这样做吗?我还将使用支持屏幕标记编辑清单文件以支持不同的大小.这就是全部吗?它还会支持我的风景或肖像模式.请确认一下.我是堆栈和android开发的新手.
编辑:我相信不同文件夹中的不同布局文件..只会是彼此的副本,只有代码中显示的文件夹名称更改广告
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Run Code Online (Sandbox Code Playgroud)
这是我的布局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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main"
tools:context="com.example.root.meeransunday.MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="200dp"
android:layout_height="90dp"
android:text="Send Mobile"
android:drawableLeft="@mipmap/sms"
android:layout_alignParentBottom="true"
android:layout_marginRight="-1dp"
android:layout_marginLeft="-3dp"
android:layout_marginBottom="-4dp"
android:onClick="message"/>
<Button
android:id="@+id/button2"
android:layout_width="200dp"
android:layout_height="90dp"
android:text="QR Code"
android:drawableLeft="@mipmap/qr"
android:layout_marginLeft="190dp"
android:layout_marginRight="-20dp"
android:layout_marginBottom="-4dp"
android:layout_alignParentBottom="true" …Run Code Online (Sandbox Code Playgroud) android ×6
ios ×3
invalidation ×1
ios9 ×1
jquery ×1
mobile ×1
objective-c ×1
screen ×1
themes ×1
uiview ×1