似乎在充气时ViewStub
in a ConstraintLayout
,生成的视图失去了所有约束。我想我们可以使用以下方法定义膨胀视图的约束ConstraintSet
,但这违背了目的ViewStub
.
有没有好的方法可以做到这一点?
有一个简单的解决方案:
在你的 ViewStub 中让inflatedId
属性与相同id
像这样:
<ViewStub
android:id="@+id/pocket_view"
android:inflatedId="@+id/pocket_view"
android:layout="@layout/game_pocket_view"
android:layout_width="@dimen/game_pocket_max_width"
android:layout_height="@dimen/game_pocket_max_height"
app:layout_constraintLeft_toLeftOf="@id/avatar_view"
app:layout_constraintRight_toRightOf="@id/avatar_view"
app:layout_constraintTop_toTopOf="@id/avatar_view"
app:layout_constraintBottom_toBottomOf="@id/avatar_view"
/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)