在纵向模式下,我从视图控制器的顶部到底部有四个视图(参见图像).
然后我想在设备转换为横向时更改视图相对于彼此的位置(参见图2).
我希望视图4与视图2和3一起移动,并且它们都位于视图1下方.
一些布局条件:
实现不同布局的最佳方法是什么?
最优雅的解决方案是在视图控制器代码中引用约束并在viewWillTransition中激活和停用它们吗?或者有没有办法使用各种特性来实现这一点(我可以想象水平居中的视图2,3和4会使这很难实现,以及在横向模式下为视图4添加新的约束)?
I have a recyclerView currently set up to add a drop shadow to the bottom of each item with spacing which works well. I want to add a thin gray border around each item as well as a soft rounding if possible. Code so far:
public class VerticalSpaceItemDecorator extends RecyclerView.ItemDecoration {
private final int verticalSpaceHeight;
public VerticalSpaceItemDecorator(int verticalSpaceHeight) {
this.verticalSpaceHeight = verticalSpaceHeight;
}
@Override
public void getItemOffsets(Rect outRect,
View view,
RecyclerView parent,
RecyclerView.State state) {
// 1. Determine whether to …Run Code Online (Sandbox Code Playgroud)