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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:22:19+00:00 2026-06-05T01:22:19+00:00

I am building an android app where the user paints some objects in the

  • 0

I am building an android app where the user paints some objects in the screen. One type of object is a Text object. The user creates the object by dragging his finger and the object is shown as a rectangle that can be moved/reshaped. When user taps the text object, I launch a new activity where user enters text which I return on the onActivityResult method.

Now I want to show the text in the object. I can have access to stuff as the coordinates of the Rectangle etc from my text class. What I want to do in essence, is to create a TextView (or EditText) programmatically and set its bounds as the bounds of my rectangle that my object is painted in. Is there a method that can help me do it?

(another approach would be to use the canvas.drawTextOnPath method in my text object. But this seems more complicated since my text might get out of the object, and I would also have to handle the multilines)

Thank you very much in advance!

EDIT: trying GAMA’s approach

protected void onActivityResult(int requestCode, int resultCode, Intent data) {                 
  switch(requestCode) { 
  case 1:
      if (resultCode == Activity.RESULT_OK) { 
            String text=data.getStringExtra("text");
            System.out.println(text);
            TextView tv=new TextView(this);
            //LayoutParams lp = new LayoutParams(new ViewGroup.MarginLayoutParams((int)texts.get(index).width,(int)texts.get(index).height));
            LayoutParams lp = new LayoutParams(new ViewGroup.MarginLayoutParams(100,100));
            //tv.setLayoutParams(lp);
            //lp.setMargins((int)texts.get(index).Sx, (int)texts.get(index).Sy, (int)texts.get(index).Lx, (int)texts.get(index).Ly);

            tv.setLayoutParams(lp);
            tv.setTextSize(10);
            tv.setTextColor(Color.RED);
            tv.setText(text);
            lp.setMargins(0,0,0,0);
            //tv.setVisibility(View.VISIBLE);
            System.out.println("got "+tv.getText());
            }
      break;
      }
  }  

both prints show the text as expected but I do not see anything in the screen (tried to set it on the bottom left to begin with)

  • 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-05T01:22:20+00:00Added an answer on June 5, 2026 at 1:22 am

    Actually, drawTextOnPath is your best bet. It won’t bleed out. All you have to do is create a path that goes from the left, center vertical of your rectangle to the right center vertical. The method will take care of resizing the text so that it will stay within the Path.

    You can adjust the path accordingly by using Paint.getTextWidth(). If the width is bigger than the box, extend your path with a line Paint.getTextHeight() below the first line.

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

Sidebar

Related Questions

I'm building an Android app that resizes based on the screen size using different
I am building an Android app & one of the functions I need is
I am building an Android app in which user are required to choose a
I'm building an Android app and I want to copy the text value of
I am building an android application that has an Application object ( App )
I'm building an Android app and I need to have two different themes for
We are looking at building a cross-platform mobile app for iPhone, Android, etc. In
I've read a lot about building UI that supports multiple screen resolutions on android.
I'm building an android app which has a login and logout option. How do
I am building an Android app. For that i want to show image at

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.