在横向模式下隐藏字段

GtO*_*kAi 2 android xamarin

有什么方法可以在横向模式下隐藏字段?基本上,我想要:

android:visibility="GONE"
Run Code Online (Sandbox Code Playgroud)

仅在横向模式下。有可能吗 用一个简单的解决方案...

我尝试了这个:

 public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
    {
        base.OnConfigurationChanged(newConfig);
        if(newConfig.Orientation == Android.Content.Res.Orientation.Landscape)
        {
// 1
        }
        else
        {
  // 2
        }

    } 
Run Code Online (Sandbox Code Playgroud)

但是不起作用。

nKn*_*nKn 5

尝试类似:

if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
  View my_view = findViewById(R.id.your_view);
  my_view.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)