我在活动标志中添加了下面的代码,它说它不存在。
ScreenOrientation = ScreenOrientation.Portrait"ScreenOrientation.Portrait“是它所说的唯一不存在的部分。我还需要添加另一个引用吗?我必须在别的地方定义它吗?其他论坛刚刚说要添加上面的代码。感谢那些花时间的人。
发布于 2014-05-14 20:08:44
使用以下活动标志,您可以强制该活动面向肖像:
[Activity (ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class YourActivity发布于 2014-05-14 19:47:38
如果要在代码中更改活动布局,请使用以下命令:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);发布于 2014-05-14 19:45:22
androidManifest.xml中的活动语法实际上如下所示:
android:screenOrientation=[
"unspecified" | "behind" |
"landscape" | "portrait" |
"reverseLandscape" | "reversePortrait" |
"sensorLandscape" | "sensorPortrait" |
"userLandscape" | "userPortrait" |
"sensor" | "fullSensor" | "nosensor" |
"user" | "fullUser" | "locked"]正如在android开发人员的清单/活动元素中描述的那样:http://developer.android.com/guide/topics/manifest/activity-element.html
要实现这一点,需要使用xamaring (您不应该编辑androidManifest.xml),需要在类的声明中添加一个自定义属性,通知编译器为<activity .../>标记生成适当的属性:
[Activity (Label="MyActivityName",
ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class MyActivity : Activity
[...]https://stackoverflow.com/questions/23663675
复制相似问题