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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:12:25+00:00 2026-05-18T08:12:25+00:00

Hey there- I’m creating a Live Wallpaper which includes text that is drawn directly

  • 0

Hey there- I’m creating a Live Wallpaper which includes text that is drawn directly to the canvas via a TextPaint and DynamicLayout object. Within my DynamicLayout Object I set the width to the canvas width, and am now looking for a way to wrap the text that extends past the canvas. Here is my text set up code:

    //token is my large text string
    TextPaint tp = new TextPaint();
    Layout sl = new DynamicLayout(token, tp, (int) canvasWidth, Layout.Alignment.ALIGN_NORMAL, 0, 0, true);
    canvas.translate(startPositionX , startPositionY);
    sl.draw(canvas);

How do I wrap this text if it extends past the canvasWidth? Any help is appreciated!

  • 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-18T08:12:26+00:00Added an answer on May 18, 2026 at 8:12 am

    Got this after a few hours… looking to StringTokenizer, finding the longest word from my string and wrapping the remaining text to that width.

    // Assume s contains a string of words
    String longestWord = "";
    StringTokenizer st = new StringTokenizer(s, " ,\t");
    while (st.hasMoreTokens()) {
        String w = st.nextToken();
        if (w.length() > longestWord.length()) {
            longestWord = w;
        }
    }
    
    float textWidth = tp.measureText(longestWord+" ");
    Layout sl = new DynamicLayout(token, tp, (int) textWidth, Layout.Alignment.ALIGN_CENTER, lineSpacing, 0, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there. I would really appreciate your help in creating a query that would
Hey there, I've got a block of HTML that I'm going to be using
Hey, is there any built in functions or something like that in php that
Hey there, I'm trying to make a site which have following: News, Products, About
Hey there, I keep hearing over and over again that I should ALWAYS use
hey there i am having problem i have List<List<memoryCard>> that i want to show
Hey there! now first of all some might want to shout that there are
hey there everyone. so, have a c# windows form that uses crystal reports and
Hey I was wondering if there were any way to upload images in ASP?
Hey, in the Programming Pearls book, there is a source code for setting, clearing

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.