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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:49+00:00 2026-05-31T05:27:49+00:00

I want to display a line with text on it but it shouldn’t be

  • 0

I want to display a line with text on it but it shouldn’t be vertical or horizontal it should be in 45° angle. I’m using for a RelativeLayout which contains a TextView and a View ( for the line). With the help of the RelativeLayout.LayoutParams I try to define the x/y position of the RelativeLayout. The horizontal display already works but how can I change it to become a 45° angle?

    RelativeLayout branch_layout = (RelativeLayout) this
            .findViewById(R.id.createrelativelayout);

    LinearLayout branch_item = new LinearLayout(this);
    branch_item.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    branch_item.setOrientation(1);
    TextView tv = new TextView(this);
    tv.setLayoutParams(new RelativeLayout.LayoutParams(pos, pos));
    tv.setId(id);
    tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    tv.setPadding(20, 0, 20, 0);
    tv.setText(branch_name);
    tv.setOnClickListener(this);

    Rect bounds = new Rect();
    Paint textPaint = tv.getPaint();
    textPaint.getTextBounds(branch_name, 0, branch_name.length(), bounds);
    View underline = new View(this);
    underline.setLayoutParams(new LayoutParams(bounds.width() + 40, 1));
    underline.setBackgroundColor(Color.parseColor("#000000"));

    branch_item_layout = new RelativeLayout(this);
    branch_item_layout.setLayoutParams(new LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    Display display = getWindowManager().getDefaultDisplay();
    //x
    params.leftMargin = display.getWidth()/2;
    //y
    params.topMargin = ((display.getHeight()/2)-(((LinearLayout) this
            .findViewById(R.id.createlinearlayout3)).getWidth()/2)-48);

    //end x
    params.bottomMargin = params.leftMargin + bounds.width();
    //end y
    params.rightMargin = (int) (params.leftMargin - (bounds.width()*Math.sin(45)));

    branch_item.addView(tv);
    branch_item.addView(underline);

    branch_item_layout.addView(branch_item, params);
    branch_layout.addView(branch_item_layout);

The whole screen implementation is only for “landscape” x 0-800, y 0-440
Right now the

first x = 400
first y = 114
end x   = 434
end y   = 371

Planned was to display the String and line together in 45° angle. The length of the line orientates on the String width.

Hope anyone can help me with this dilemma,

Saskia

  • 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-31T05:27:49+00:00Added an answer on May 31, 2026 at 5:27 am

    the problem because of the x and y position was that the relativelayout became very huge.
    So I removed the layout branch_item_layout and add the parameter and animation stuff on branch_item.

    See you,

    Saskia

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

Sidebar

Related Questions

I want to know which component is best to display multiple line of text's(
I want to display a straight line graph using AMChart. But it does not
I want to display float elements in one line without using tables. When a
So, I want to display titles and excerpt in line with images? How can
I want to read a specific line of a RSS feed to display the
I display some text but not all of the text is shown so I
Should have been very easy but somehow cannot get it to work. I want
I'm trying to display two <div> elements on the same line, but in the
I have a listbox that should display data that contains 2 fields: time and
It seems to me that the following code should display text right in 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.