标签: screen-orientation

Cordova:如何在启动时将应用程序方向锁定为横向而不是横向反转?

我正在构建一个基于倾斜的游戏,并希望将方向锁定为 1 个特定的横向方向(iOS 上的 UIInterfaceOrientationLandscapeRight)。但是,如果您将 cordova Orientation 首选项设置为landscape,它仍然可以旋转 180 度到任一横向模式,这对我来说是不可接受的。这是cordova的缺点吗?我需要这个,而且本地做起来很简单,所以似乎应该有一个简单的方法来做到这一点。

我知道cordova-plugin-screen-orientation,但它只有在你的 javascript 开始运行后才会执行操作,这对于你的启动屏幕来说已经太晚了。

orientation screen-orientation cordova

3
推荐指数
1
解决办法
4455
查看次数

禁用Android上的屏幕旋转

当我按下按钮时,我想在我的所有活动中禁用屏幕旋转.我怎样才能做到这一点?

顺便说一句,当用户点击按钮时,手机可以位于横向或纵向位置.

android screen-orientation

2
推荐指数
1
解决办法
2万
查看次数

评估orientationEvent并设置一个值?

如果在发生方向更改时触发了onChange函数,如何在onChange中设置将更新jquery选择器的值.例如:

  $(document).ready(function(){    
    var onChanged = function() {
            if(window.orientation == 90 || window.orientation == -90){
                image = '<img src="images/land_100.png">';
            }else{
                image = '<img src="images/port_100.png">';
            }
     }
        $(window).bind(orientationEvent, onChanged).bind('load', onChanged);
        $('#bgImage').html(image); //won't update image
   });
Run Code Online (Sandbox Code Playgroud)

jquery orientation screen-orientation device-orientation

2
推荐指数
1
解决办法
6541
查看次数

半透明设置时没有方向通知

使用已android 2.1 & 2.2安装的手机,使用最简单的hello world应用程序并将 android:theme ="@ android:style/Theme.Translucent"添加到android清单中的活动以使应用程序透明,该应用程序坚持为肖像仅旋转电话时不会旋转到横向.

拿出线,应用程序旋转正常.这可以通过override of onConfigurationChanged在该例程中添加和放置断点来验证.Brk在未应用半透明时命中,在添加半透明时不会.

但是,使用andr 2.2使用三星星系标签,即使使用半透明,旋转也能正常工作.任何人对此都有任何想法?

android themes screen-orientation

2
推荐指数
1
解决办法
805
查看次数

从代码中将方向设置为纵向

我知道我可以限制清单文件的方向.像这样

android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)

但是可以从代码中设置方向吗?

例如,可以从清单和代码中将活动设置为全屏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

android portrait manifest orientation screen-orientation

2
推荐指数
1
解决办法
4550
查看次数

在屏幕方向更改时恢复对象

在我的代码中,我创建了一个卡类; 我稍后在gridview中展示了一堆卡片.在屏幕方向改变时,我正在丢失所有卡片; 在我之前的问题中,我指出了正确的方向.

现在,我在Android文档中找到的内容以及StackO中的内容就是这样

@Override
    protected void onSaveInstanceState(Bundle outState) {
    outState.putInt(...);
    super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    some_int_var = savedInstanceState.getInt(...);
super.onRestoreInstanceState(savedInstanceState);
Run Code Online (Sandbox Code Playgroud)

}

现在,我这样做好,因为Bundle对象有几个方法,如putString,Char等.原语加上字符串.但我的卡怎么样?它们是向量中的Card对象,因此我不能使用任何这些方法.

如何在不使用onRetainNonConfigurationInstance的情况下恢复该向量,也不会阻止活动重置?在Android文档中,如果要重新启动重型数据,建议执行此操作,但这不是我的情况.

android reset screen-orientation

2
推荐指数
1
解决办法
978
查看次数

屏幕旋转后,Android Imageview会显示旧的位图

我的应用程序应该首先显示图像,当按下按钮时,另一个图像显示在图像视图中.但是,当旋转屏幕时,imageView会显示旧图像.我该怎么办呢?(bits是在创建时加载到imageView的Bitmap)

我的代码如下:

    RGBToBitmap(rgb.getWindow(), bits); //this loads a new image into bits

    imageView.setImageBitmap(bits);
Run Code Online (Sandbox Code Playgroud)

android bitmap screen-orientation imageview

2
推荐指数
1
解决办法
4817
查看次数

astuetz/PagerSlidingTabStrip旋转设备时选中的选项卡错误

当我旋转设备并且如果我选择了除第一个或最后一个之外的某个选项卡,它会向我显示选项卡的错误位置.

但当我做一个小触摸手势时,它会更新自己.你知道怎么解决这个问题.

android screen-orientation pagerslidingtabstrip

2
推荐指数
1
解决办法
705
查看次数

如何在phonegap中使用插件来改变屏幕方向?

我的phonegap应用应该以纵向方式运行.只能在横向模式下运行一个页面(index.html).然后我找到了这个插件,但对我不起作用.

cordova plugin add net.yoik.cordova.plugins.screenorientation

在config.xml中:

<preference name="orientation" value="portrait" />

index.html的:

<html>
<head>
<title>App</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script>
var so = cordova.plugins.screenorientation;
so.setOrientation(so.Orientation.LANDSCAPE);
</script>
Run Code Online (Sandbox Code Playgroud)

对于android,应用程序返回错误App has stopped.

对于iPhone,没有任何事情发生.

iphone android screen-orientation cordova

2
推荐指数
1
解决办法
5323
查看次数

如何区分16:9显示屏和18:9显示屏?

在我的Android应用中,我使用不同的Android资源目录来支持多种屏幕尺寸和方向。所以在res我里面有一个layout文件夹,一个layout-land文件夹,一个layout-large文件夹,一个layout-large-land文件夹等等。

在我尝试将我的应用安装到具有18:9显示屏而不是显示屏的较新手机中之前,这种方法对我来说非常有效16:9

该电话从layoutlayout-land文件夹中提取资源,这意味着它将被注册为“常规”屏幕。

此外,如果我尝试使用以下代码获取此手机的屏幕尺寸,

int screenSize = getResources().getConfiguration().screenLayout &
                Configuration.SCREENLAYOUT_SIZE_MASK;


        switch(screenSize) {
            case Configuration.SCREENLAYOUT_SIZE_XLARGE:
                Toast.makeText(this, "Extra Large Screen", Toast.LENGTH_LONG).show();
                break;
            case Configuration.SCREENLAYOUT_SIZE_LARGE:
                Toast.makeText(this, "Large Screen", Toast.LENGTH_LONG).show();
                break;
            case Configuration.SCREENLAYOUT_SIZE_NORMAL:
                Toast.makeText(this, "Normal Screen", Toast.LENGTH_LONG).show();
                break;
            case Configuration.SCREENLAYOUT_SIZE_SMALL:
                Toast.makeText(this, "Small Screen", Toast.LENGTH_LONG).show();
                break;
            default:
                Toast.makeText(this, "Screen size is neither xlarge, large, normal or small", Toast.LENGTH_LONG).show();
        }
Run Code Online (Sandbox Code Playgroud)

然后再次将其注册为正常屏幕。但是具有16:9显示屏的手机也是如此。不用说,这在这两款手机上的应用外观上产生了微小但明显的差异。

所以我的问题是,有没有办法区分这两种显示?

注意:我知道有一些解决方法,例如dp …

android screen-orientation android-layout screen-size android-resources

2
推荐指数
1
解决办法
1120
查看次数