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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:25:35+00:00 2026-06-16T04:25:35+00:00

given a string in resources, how can I get the bounding rectangle for it?

  • 0

given a string in resources, how can I get the bounding rectangle for it?

For plain text, I could use Paint.getTextBounds(), but this is a string from resources that has newlines and attribute settings in it.

<string name="foobar"><small>Foo</small>\nBar</string>

In other words, I’m implementing a custom view that will be displaying a string like that, and I want to compute the size of my view.

More detail: Basically, I’m implementing a variant of TextView that adjusts its font size to fit the available space rather than one that adjusts its size to fit the text.

  • 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-16T04:25:36+00:00Added an answer on June 16, 2026 at 4:25 am

    You want to show html in your custom view. Do i make it clear?

    If you want to implements this all by your own code. It is a very huge work. Extending TextView and overriding some methods is the best choice, but if you insist on writing your own class, you can still get help from some system class.

    Showing and measuing html should follow the code of TextView, you can find this in TextView.onDraw() and TextView.onMeasure(), here i just talk about the steps for measuring html.

    1. Parsing html. Use Html.fromHtml() to get a Spanned text.
    2. Create a StaticLayout or DynamicLayout with the spanned text.
    3. Use Layout.getLineWidth() and Layout.getHeight() to measure the text.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What regular expression can I use (if any) to validate that a given string
I followed this guide which I was recommended , but I can't get it
I get this error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 4:
I've used Virtual attributes in the past but I can't seem to get past
I'm trying to get started with Hibernate, but can't insert data, for some reason.
I know there are plenty of resources on this but I'm having a tough
I was given a link to use this library for connection through SSH connection
Is it possible to get text (line or sentence) from a given line number
I might be missing something here, but in ASP.NET MVC 4, I can't get
I'm trying to compress any given string to a shorter version, copy paste-able compressed

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.