Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9207919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:29:46+00:00 2026-06-18T00:29:46+00:00

I have a LinearLayout that I use to make a box to display a

  • 0

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): Date Box

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:29:48+00:00Added an answer on June 18, 2026 at 12:29 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawable that i use as a Background for a LinearLayout. I
I have a LinearLayout that I would like to change the background color of
I want to make use of the android xml layouts. I have put a
I have a LinearLayout that comprises some number of TextViews. I set android:gravity=center_horizontal for
I have a RelativeLayout inside a LinearLayout which I use to display some data:
I have a code that should get a LinearLayout (with more LinearLayout's inside), and
There is one image on LinearLayout. I have to move that image in any
I am using a GridView that shows a linearlayout with a background image plus
I'm trying to make a layout that is something similar to how the android
I have in my Android app a fairly simple Activity that displays three buttons,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.