我的代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/myCustomShapeDrawable"
android:orientation="horizontal" >
<View
android:layout_height="match_parent"
android:layout_width="0.4px"
android:layout_gravity="center"
android:background="#cccccc"/>
</LinearLayout>
如您所见,第一个问题是线的高度与 LinearLayout 的高度不匹配,尽管其高度属性中有“match_parent”。第二个问题是它没有在 LinearLayout 的中心对齐。