I have a LinearLayout that I use to make a box to display a date:
<LinearLayout android:id="@+id/date_layout"
android:background="@drawable/bg_frame"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:layout_rowSpan="3"
android:minWidth="65dp"
android:orientation="vertical"
>
<TextView android:id="@+id/date"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="@android:color/holo_blue_bright"
android:textSize="20sp"
/>
<View
android:background="@android:color/holo_blue_bright"
android:layout_height="1dp"
android:layout_width="match_parent"
/>
<TextView android:id="@+id/day_of_week"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="@android:color/holo_blue_bright"
/>
</LinearLayout>
It makes a nice little box (this is without the View in the above code): 
When I put the View in there, it stretches the box all the way across the screen, I just want to draw a line across the width of the box without changing its width, why does it not work as I have it coded? Shouldn’t the android:layout_width="match_parent" simply match the width of the containing LinearLayout? Why does it work for the two TextViews and not the View?
The LinearLayout is contained in a GridLayout.
I’ve also found that if I replace the View with a TextView, but leave all else exactly the same, it works as I want it to and doesn’t expand to fill the whole screen width. Why does TextView work like I expect and View not?
YOu don’t have a layout_width or layout_height on the LinearLayout. So its width and height are undefined, and probably defaulting to fullscreen. You need to set its width to wrap_content.