orientation

How to set landscape orientation mode for flutter app?

落花浮王杯 提交于 2020-05-08 08:10:13
问题 I was looking for code which can set orientation of my flutter app landscape forcefully. 回答1: Enable forcefully Import package: import 'package:flutter/services.dart'; in main.dart file 1. Landscape mode: // Set landscape orientation SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); 2. Portrait mode: // Set portrait orientation SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitDown, DeviceOrientation.portraitUp, ]);

SwiftUI Force Portrait On All Except One View

时光总嘲笑我的痴心妄想 提交于 2020-04-16 03:29:45
问题 I have a SwiftUI project. For all but one of the views, I want to allow portrait and only portrait mode. For only one view, I want to allow both portrait and landscape. There are some resources on Swift but I couldn't find any on SwiftUI. Did anyone find a way to accomplish this? 回答1: I had to do something similar to this. Here's our approach. We set the project orientation to only support Portrait mode. Then in your AppDelegate add an instance variable for orientation and conform to the

How to change Device Orientation programmatically in Swift?

冷暖自知 提交于 2020-04-15 08:37:42
问题 In my app I want to change the device orientation. I`ve tried it like in the other question with the same topic: let value = UIInterfaceOrientation.landscapeRight.rawValue UIDevice.current.setValue(value, forKey: "orientation") But this seems only to work if the orientation is already allowed so that the user can change it with rotating the device, and it also change the orientation with an animation. But I want my app to only have one orientation in VC1 and to have only one orientation in

Device camera direction excluding device landscape/portrait orientation

对着背影说爱祢 提交于 2020-04-13 06:23:30
问题 I need to get the direction of the front facing camera excluding the devices orientation (landscape/portrait). I tried to represent this using Core Motion and accessing device attitude. Here I tried to access the Euler angles and exclude the yaw, however this doesn't seem to work as when rotating the device more that one Euler angle value changes. I am also considering using the orientation quaternion but I don't have experience using them. I need this information in a serialisable manner as

IOS8 Autolayout with relative width / height

不羁的心 提交于 2020-04-11 05:09:11
问题 I need to autolayout a storyboard UIView with a single UIControl. The UIControl should be centered, needs to have a aspect ratio of 1:1 and should always use 90% of the superviews width or height depending on the device orientation without clipping. I added 4 constraints Center Y Alignment - View - Superview Center X Alignment - View - Superview Equal Widths - View - Superview with multiplier set to 0.9 Aspect Ratio - View - View with multiplier set to 1:1 This setup works fine in portrait

(译)响应式图片— srcset 和 sizes 属性

大憨熊 提交于 2020-04-07 21:38:33
在响应式网页设计的革命中,图片看起来是被浪潮落下的一个事物。直到最近,根据不同的屏幕尺寸和像素密度来提供不同的图片还是没有完全实现。 <picture> 元素展示了很多改变这个局面的希望,但无论picture元素是否可以完全使用,现在有两个对于响应式图片很关键的两个属性 —— srcset 和 sizes 。 srcset 属性 srcset 属性允许我们可以提供一系列也许可以被浏览器使用的图片资源。我们提供一个以逗号为分割的图片list,user agent会根据设备特性来决定哪一张图片来显示在网页上。 当listing图片时,我们提供每张图片两个信息 —— 图片文件的_路径_ 图片文件的_宽度_或者_像素密度_ 为了定义_像素密度_,我们添加一个 x 来表示图片的密度数值。举个栗子 —- <img src="one.png" srcset="two.png 2x, three.png 3x, four.png 4x"\> 在图片 src 中定义的默认为图片的 1x 。 在2012年 srcset 属性第一次提出时,我们只能提供不同的像素密度的图片,就像上面例子中显示的。然而,在2014年新添加了 width 属性,它可以使我们根据不同的宽度来提供不同的图片。 为了指定图片的宽度,我们添加一个 w 来表示图片的像素宽度。举个栗子 —- <img src="one.png"

有时候横竖屏切换的时候有没自动加载layout布局文件知道为什么吗?

烂漫一生 提交于 2020-04-07 12:29:47
我大概知道原因,但还是不知道确切原因。在我的Mainfester.xml中的有些activity是android:configChanges="keyboardHidden|orientation"有些是android:configChanges="keyboardHidden|orientation|screenSize",后者会出现切换屏幕不会重新加载对于的资源文件。说明没有重新启动activity,(据说从Android 3.2 ( API level 13)开始,"screen size"也随着设备的横竖屏切换而改变。因此,如果你在 API level 13或更高(minSdkVersion和targetSdkVersion属性声明)进行开发时,要防止因方向改变而重新启动,你必须为" orientation "添加"screen size"值。),如果这样的话,那是不是我的每个activity中都要对我的onConfigurationChanged进行处理以保证屏幕加载正确和数据的完整?这样感觉好麻烦,每个都要加正确的做法是不是这样???? 来源: https://www.cnblogs.com/NuoChong/p/12652543.html

如何在 Android 程序中禁止屏幕旋转和重启Activity

喜欢而已 提交于 2020-03-22 10:25:42
禁止屏幕随手机旋转变化 有时候我们希望让一个程序的界面始终保持在一个方向,不随手机方向旋转而变化: 在AndroidManifest.xml的每一个需要禁止转向的Activity配置中加入 android:screenOrientation =”landscape” 属性。 landscape = 横向 portrait = 纵向 避免在转屏时重启Activity android中每次屏幕方向切换时都会重启Activity,所以应该在Activity销毁前保存当前活动的状态,在Activity再次 Create的时候载入配置,那样,进行中的游戏就不会自动重启了! 要避免在转屏时重启Activity,可以通过在AndroidManifest.xml文件中重新定义方向(给每个Activity加上 android:configChanges =”keyboardHidden|orientation” 属性)。 在需要控制屏幕显示方向的Activity中重写 onConfigurationChanged(Configuration newConfig) 方法,这样在转屏时就不会重启Activity了。 if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE) { //横向 setContentView(R.layout

AndroidManifest.xml

ぃ、小莉子 提交于 2020-03-18 08:28:40
<activity> 中:    android:name="" //对应的java文件    android:configChanges=""     对 Android :configChanges属性,一般认为有以下几点:       1、不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏时会执行两次       2、设置Activity的android:configChanges="orientation"时,切屏还是会重新调用各个生命周期,切横、竖屏时只会执行一次       3、设置Activity的android:configChanges="orientation|keyboardHidden"时,切屏不会重新调用各个生命周期,只会执行onConfigurationChanged方法     但是,自从Android 3.2(API 13),在设置Activity的android:configChanges="orientation|keyboardHidden"后,还是一样会重新调用各个生命周期的。因为screen size也开始跟着设备的横竖切换而改变。所以,在AndroidManifest.xml里设置的MiniSdkVersion和

[android] AndroidManifest.xml - 【 manifest -> Application -> activity 】

感情迁移 提交于 2020-03-18 08:26:14
<activity android:allowTaskReparenting=["true" | "false"] android:alwaysRetainTaskState=["true" | "false"] android:clearTaskOnLaunch=["true" | "false"] android:configChanges=["mcc", "mnc", "locale", "touchscreen", "keyboard", "keyboardHidden", "navigation", "screenLayout", "fontScale", "uiMode", "orientation", "screenSize", "smallestScreenSize"] android:enabled=["true" | "false"] android:excludeFromRecents=["true" | "false"] android:exported=["true" | "false"] android:finishOnTaskLaunch=["true" | "false"] android:hardwareAccelerated=["true" | "false"] android:icon="drawable resource" android