原因/Why
- 本文代码分析基于Android 9
- Base on Android 9
近期开始一款机顶盒的开发,测试中发现安装一些应用(通常是只针对手机)的时候,由于应用设置仅支持竖屏,会导致在电视端显示异常。
Some Application which only support vertical works fine with Android phone,but Android TV
可通过本文方法使得仅支持竖屏的应用能够在电视端正常显示。
following the content to let these applications work well.
通过查看此代码得知,AOSP已经有相关内容支持
The source code shows how to let the application force orientation.
因此只需要进行如下修改即可
Just do this to support force orientcation.
修改代码的表达式值为true
Change the source code value to true
Modify the calculateBounds
method
1 | private void calculateBounds(Rect out) { |
再次编译framework代码即可
Build the AOSP again.