che*_*hie 1 android android-constraintlayout constraint-layout-chains
我有一个简单的水平链接视图布局,具有 spread_inside 链样式。当我尝试使用偏差属性将视图移动到所需位置时,我发现偏差属性被忽略。
以下是布局供参考:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<View
android:id="@+id/view_1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@android:color/black"
app:layout_constraintEnd_toStartOf="@id/view_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view_2"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="@android:color/black"
app:layout_constraintEnd_toStartOf="@id/view_3"
app:layout_constraintStart_toEndOf="@id/view_1"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view_3"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@android:color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.2"
app:layout_constraintStart_toEndOf="@id/view_2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
在这里,我想使用layout_constraintHorizontal_bias属性将view_3移近view_2。我怎样才能做到这一点?
如果您在视图中使用水平链,则水平偏置不起作用(因为您在同一轴上进行偏置,如果存在水平链,则垂直偏置将起作用,反之亦然);除非您想将其应用到创建的链的头部视图(水平链中的最左侧视图和垂直链中的最顶部视图);这不是你的情况,在这里。此外,仅当选定的链条样式已包装时,对链条的头部视图应用的偏置才起作用。因此,您应该尝试找到一些其他解决方法来实现您想要的 UI 并忽略链的使用(此处)。
有关更多信息,请参阅:使用 ConstraintLayout 构建响应式 UI
希望我的回答对你有帮助。
| 归档时间: |
|
| 查看次数: |
4369 次 |
| 最近记录: |