背景:
android-7.1.1_r12
api中,android.hardware.camera2
使用StickyBottomCaptureLayout
作为“BottomBar”
显示操作按钮(例如切换摄像头、快门和最近照片等按钮)。无论设备方向如何,这个StickyBottomCaptureLayout
始终显示在系统栏的上方/附近(其中包含返回、主页和其他应用程序按钮)。
例如,当旋转角度为0
或180
时,其外观如下:
通过将设备旋转并获得旋转角度为90
或270
,StickyBottomCaptureLayout
现在接近系统栏:
通常,这个截图应该让粘性工具栏在左侧,相机在右侧...
尝试:
I firstly tried to set different layout with
layout-land
, but no luck! I cannot change the default left-to-right orientation and get the bottom bar sticks to the Android system bar on270
degrees.I cannot extend these widgets, but I tried to reproduce the case. For example, I got two layouts:
<FrameLayout> <ViewGroup .../> // containing the upper views <StickyBottomBar .../> // same behavior as StickyBottomCaptureLayout </FrameLayout>
On each orientation changes, I get the rotation's device and set the correct gravity for upper layout and the sticky bar, something as follows:
if (rotation == 0) { // views gravity = TOP // sticky gravity = BOTTOM } else if (rotation == 90) { // views gravity = LEFT // sticky gravity = RIGHT } else if (rotation == 180) { // views gravity = BOTTOM // sticky gravity = TOP } else if (rotation == 270) { // views gravity = RIGHT // sticky gravity = LEFT }
问题:
是否有人有解决方案来模拟底部栏在设备方向改变时的情况(始终在Android系统栏上方或附近)?请记住,我的最小SDK低于21,因此我无法访问android.hardware.camera2 api。