In the android-7.1.1_r12 api, the android.hardware.camera2 uses a StickyBottomCaptureLayout as a \"BottomBar\" to display the ac
I just found the solution: I need to set a RectF for each layout and set them with the right coordinates. From the source class, I manage to do this:
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
// rotation from context Surface.ROTATION
int degrees = getDeviceRotation(getContext());
// size of the sticky bottom bar
int offsetSize = (int) getResources().getDimension(R.dimen.sticky_bar_default_size);
// layout sticky bottom bar
RectF bottomBarRect = getStickyBarRect(degrees, offsetSize);
mBottomBar.layout((int) bottomBarRect.left, (int) bottomBarRect.top,
(int) bottomBarRect.right, (int) bottomBarRect.bottom);
// layout upper view
RectF upperViewRect = getUpperViewRect(degrees, offsetSize);
mUpperView.layout(...); // same logic as above
invalidate();
}
// Gets the coordinates positions to set the Sticky Bottom Bar
private RectF getStickyBarRect(int degrees, int offsetSize) {
float left = 0, top = 0, right = 0, bottom = 0;
int width = getWidth();
int height = getHeight();
if (degrees == 0) { // stickybar at bottom
top = height - offsetSize;
right = width;
bottom = height;
} else if (degrees == 90) { // stickybar at right
left = width - offsetSize;
right = width;
bottom = height;
} else if (degrees == 180) { // stickybar at top
right = width;
bottom = height - offsetSize;
} else if (degrees == 270) { // stickybar at left
right = offsetSize;
bottom = height;
}
return new RectF(left, top, right, bottom);
}
// Gets the coordinates positions to set the upper views
private RectF getUpperViewRect(int degrees, int offsetSize) {
// same logic as getStickyBarRect()
}
And this works as expected!
I found a way to reproduce the smooth orientation like the native camera2 app with this answer. Using an orientation listener and the configChanges options, I'm able to reorganize the views without the default rotation animation. I set the proper positions in onLayout() and call invalidate(). ;)