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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:00:20+00:00 2026-05-22T21:00:20+00:00

If a TextView does not have enough space in its parent element, I will

  • 0

If a TextView does not have enough space in its parent element, I will show an icon. A tab on that text or the icon will be used to call an alert dialog with the full string. So i need to know if a TextView has been trinmmed.

  • 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-22T21:00:21+00:00Added an answer on May 22, 2026 at 9:00 pm

    Claculate the width of TextView and also calculate the width of text which wil be displayed in the textview. If the width of text is more that the width of textView that means your have to call dialog because because the text will be marqued. Otherwise the text completely fit in the TextView without any issue so no need of dialog box.

    use the following code.

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        // TODO Auto-generated method stub
        super.onWindowFocusChanged(hasFocus);
    //  System.out.println("...111Height..."+mainLayout.getMeasuredHeight());
    
        isMarqueed("I am fine here. How r u", textView.getWidth(), textView);
        isMarqueed("I am fine", textView.getWidth(), textView);
    }
    
    
    private boolean isMarqueed(String text, int textWidth, TextView tv) { 
        Paint testPaint = new Paint();
        testPaint.set(tv.getPaint());
        boolean isMarquee = true;
        if (textWidth > 0) {
            int availableWidth = (int) (textWidth - tv.getPaddingLeft() - tv.getPaddingRight()-testPaint.measureText(text));
            System.out.println("...available width..."+availableWidth);
    //        tv.setText(text);
            isMarquee = false;
        }
        return isMarquee;
    }
    

    Thanks
    Deepak

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

Sidebar

Related Questions

I am trying to create a simple Icon+Text ListView but it does not work.
CheckBox Text Does Not Change on Orientation Change I have differing layout files (one
I have a clickable TextView with a drawable as its background. I'm looking for
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have a textview inside ViewPager . I am using PagerAdapter to show the
I have a UIPresentationFormSheet (contains a textview) that appears in the center of the
I have a TextView that I created in the main.xml. In my app.java I
I have the following TextView defined: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/txtCredits" android:autoLink="web" android:id="@+id/infoTxtCredits" android:layout_centerInParent="true" android:linksClickable="true"/>
My Custom Adapter that extends SimpleCursorAdapter for my ListFragment does not display the items
I have an android loyout like this: <ScrollView android:layout_width=fill_parent android:layout_height=fill_parent android:id=@+id/scrollview> <TextView android:id=@+id/text android:layout_width=wrap_content

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.