问题描述
我希望分隔一些登录/注册表单的分隔线的厚度更小。遵循了所有良好的布局实践 - 在 Activity 中使用了 ConstraintLayout,并且已将约束设置为与父项匹配。
Here is how my application looks like
这是一个分隔符的活动布局 XML 部分(它们都是相同的):
<View
android:id="@+id/signup_divider"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="500dp"
android:layout_marginBottom="156dp"
android:background="?android:attr/listDivider"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
提前致谢。
解决方法
在处理 ContraintLayout 及其匹配的父高度约束 (0dp) 时,它可以拉伸到超出我视觉上想要的空间,从而导致更厚的分隔线。
因此,我们可以使用静态高度(厚度)作为视觉上吸引人的分隔线。一旦我将其设置为:
android:layout_height="1dp"