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 1011401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:13:43+00:00 2026-05-16T09:13:43+00:00

In my application I need to set dynamic text to my textview so I

  • 0

In my application I need to set dynamic text to my textview so I want it to get resized dynamically. I have set:

<TextView
android:id="@+id/TextView02" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="normal"
android:text="Frontview"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="#0099CC"
android:singleLine="false"
android:maxLines="4"
android:ellipsize="marquee"
/>

My textview height is not going beyond 2 lines and the text is getting cut.

  • 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-16T09:13:44+00:00Added an answer on May 16, 2026 at 9:13 am

    As Konstantin said, this code will probably be ignored after you exceed 4 lines unless you remove android:maxLines="4"

    This is how you would set the height in code:

    TextView tv = (TextView) findViewById(R.id.TextView02);
    int height_in_pixels = tv.getLineCount() * tv.getLineHeight(); //approx height text
    tv.setHeight(height_in_pixels);
    

    If you want to use dip units, which allows your app to scale across multiple screen sizes, you would multiply the pixel count by the value returned by getResources().getDisplayMetrics().density;

    This depends on your desired behavior, but you might also consider having the TextView size fixed, and allowing the user to scroll the text:

    TextView tv = (TextView)findViewById(R.id.TextView02);
    tv.setMovementMethod(ScrollingMovementMethod.getInstance());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I need to set dynamic text to my textview so I
I have an .NET 4.0 application using Caliburn.Micro. I want to create a dynamic
I have a java application I need to pass some info to a C++
I am using Dynamic Data Web Entities Application website and need control of the
I need to make my application height dynamic based on the size of a
I'm making a large and complex application and I need to set tabindexes to
I'm moving an application onto Heroku and subsequently realised I'll need to set up
I've created an application in netbeans IDE 6.9 where I need to set values
I need to set image source dynamically, please note my image is in somewhere
I have an MQ application that I need to use SSL connections with. I

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.