My code:
<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>
As you can see, the first problem is that the line's height is not matching the LinearLayout's height, despite having "match_parent" at its height attribute. The second problem is that it doesnt align itself in the center of the LinearLayout.

This below code will work according to the requirement: