2
我有一个ConstraintLayout
内部的视图(Linearlayout
)具有以下属性:删除/编辑ConstraintLayout内部视图的约束编程
android:id="@+id/myView"
app:layout_constraintTop_toBottomOf="@+id/anotherView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
在一些场合,我要对齐myView
到左侧,由只是删除正确的约束。但是我无法这样做。
我试着用下面简单地复制和应用的约束参数:
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(holder.myView.getLayoutParams());
holder.myView.setLayoutParams(layoutParams);
但layoutParams
始终接收设置空参数,并将着眼于左上角。也许是因为我在recyclerView
内部使用这个?
它的外观的recyclerView
内:
public void onBindViewHolder(final RecyclerView.ViewHolder basicHolder, int position) {
ProfileAdapter.UserInfoViewHolder holder = (ProfileAdapter.UserInfoViewHolder) basicHolder;
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(holder.myView.getLayoutParams());
holder.myView.setLayoutParams(layoutParams);
}