【问题标题】:Is there any way to rotate only a few elements on screen rotation (instead of whole screen)?有没有办法在屏幕旋转时只旋转几个元素(而不是整个屏幕)?
【发布时间】:2016-06-26 17:52:33
【问题描述】:

目前我正在尝试正确显示图像/视频 (How can i rotate image and video if it was captured in landscape mode?),作为解决方案之一,我看到了这个(覆盖屏幕旋转方法并阻止某些元素使用它)。

可以吗?

我可以随时调用元素的旋转吗?

【问题讨论】:

    标签: android rotation screen-orientation screen-rotation


    【解决方案1】:

    您是否尝试过使用 ViewStub 并针对当前屏幕方向为该元素附加布局?

    ViewStub stub = (ViewStub) findViewById(R.id.stub);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
       stub.setLayoutResource(R.layout.landscape);
    } else {
       stub.setLayoutResource(R.layout.portrait);
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-19
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多