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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:37:19+00:00 2026-06-04T16:37:19+00:00

Here is a short question about how best to handle text truncation. Do you

  • 0

Here is a short question about how best to handle text truncation. Do you know a good way to show the full string to the user when it gets cut off by a TextView?

Any size screen might chop the text of a long string set in a TextView. The problem becomes more noticeable when an app is supporting multiple sizes, specifically normal and large size screens.

One good suggestion is to make the text view scrollable. My problem with that suggestion is that I have planned swipe navigation interactions in all four directions and that complicates the text view scroll. I raised this question in Android Office hours today. Any suggestions, especially those based on existing solutions, would be welcome. Thanks in advance…

  • 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-04T16:37:20+00:00Added an answer on June 4, 2026 at 4:37 pm

    One way to hande the problem was to add a property to the textview that will make it scrollable without adding code:

    android:lines="3"
    android:textIsSelectable="true" 
    android:fadeScrollbars="false"
    

    This was suggested by a member of the Android Dev Relations team during office hours. However, when tested, scroll was not working on Android version 2.2.2. My new solution is to declare the textview clickable and use the onClick callback to open a dialog.

    So now I ellipsize the text (no more scroll tags) to give the user a clear indication that the text got cut off. Here is the xml:

    android:lines="3"
    android:clickable="true"
    android:onClick="showDef"
    android:ellipsize="start"
    android:isScrollContainer="false"
    

    and here is the showDef method:

    public void showDef(View v) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("same text as was set in the text view")
            .setCancelable(false)
            .setNegativeButton("Clear", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
               }
            });
    
    AlertDialog alert = builder.create();
    alert.show()
    

    I like this solution better than simple scrolling in the case where the view group containing the textview has a fixed size. I hope it works for you, too,.

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

Sidebar

Related Questions

Okay, here's my short question: I know that === and !== operators will compare
Short question - how do you define your view models? Here are some of
First question here: it is a very short yet fundamental thing in Java that
Sort of a methods/best practices question here that I am sure has been addressed,
I know this is quite a vague question -- sorry about that. If I
I asked another question: https://stackoverflow.com/questions/1180240/best-way-to-sort-1m-records-in-python where I was trying to determine the best approach
I just have a short question about switching the color of sifr objects on
Yesterday I asked a question here about a oneliner and mjschultz gave me an
a short question about optional regex : imagine a given page thats currently rewritten/beautified
Hi there I have a short question about database design. I also tried the

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.