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

  • SEARCH
  • Home
  • 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 6769553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:26+00:00 2026-05-26T15:12:26+00:00

Can someone tell me why is the text in this layout is centered horizontally

  • 0

Can someone tell me why is the text in this layout is centered horizontally while in landscape mode, but becomes left-aligned in portrait mode?

EDIT:
Its that way because there’s no pixel limit specified for text width (ie 500dip). So if its wrap_content, android simply flows the text across all of available space. I guess its a “correct” behaviour for a text component, but completely unwanted.

<LinearLayout android:id="@+id/progressLayout2"
    android:layout_height="wrap_content" android:layout_width="wrap_content"
    android:layout_centerHorizontal="true" android:layout_centerVertical="true"
    android:orientation="vertical">

    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" android:text="@string/splash_text"
        android:id="@+id/heading_splash_text" android:textSize="45dip"
        android:textColor="#A00000" android:layout_alignParentTop="true"
        android:layout_gravity="center" android:paddingBottom="70dip"
        android:paddingTop="50dip" android:typeface="normal" android:textStyle="bold"/>

</LinearLayout>

  • 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-05-26T15:12:26+00:00Added an answer on May 26, 2026 at 3:12 pm

    I agree with some of the changes from the first answer, but I assume since you have ‘wrap_content’ on the linear layout, and you don’t have the namespace thing on there, this layout is inside some other stuff.

    First, you pretty much need the ‘fill_parent’ width, even if you don’t do height. Where the gravity should be specified is generally confusing, but the following works. I added a background color on the text so you can see where that is relative to everything else.

    Add back in padding if needed.

    <LinearLayout
              android:layout_height="fill_parent"
              android:layout_width="wrap_content"
              android:orientation="vertical"
              android:layout_gravity="center"
        >
    
    <TextView android:layout_height="wrap_content"
              android:layout_width="wrap_content"
              android:text="Some text"
              android:textSize="45dip"
              android:textColor="#A00000"
              android:typeface="normal"
              android:background="#444444"
              android:textStyle="bold"/>
    

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

Sidebar

Related Questions

I can't seem to get this text to align vertically. Can someone please tell
Can someone tell me why this doesn't work: $(document).ready(function() { $(#cookie).text(expanded); //panel toggle $(.btn-slide).click(function()
Can someone tell me why this is not displaying the form? If I go
Can someone tell me how to change directories using FtpWebRequest? This seems like it
Can someone tell what is wrong with this query? sqltext = SELECT utyp, count(*)
Can someone tell me what the code equivelant in VB.Net to this C# code
Can someone tell me why this processes all the files and then does it
Can someone tell me why this is executing the POST method instead of my
Can someone tell me what I'm doing wrong to package this as a module:
can someone please tell me why this isn't working? For some reason I need

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.