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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:28:28+00:00 2026-05-30T04:28:28+00:00

I have a pretty simple layout – an image on the right with text

  • 0

I have a pretty simple layout – an image on the right with text on the left. The text should wrap and not overlap the image. Both are centered vertically to the final height of the container.

RelativeLayout looked appropriate, aligning the image to the parent’s right edge, and the textview’s right edge with the image’s left edge. The docs make it sound like RelativeLayout.LEFT_OF should do this.

Here’s what I have. The text overlays the image. I need the textview to be only as large as the available space.

LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
lp.addRule(RelativeLayout.CENTER_VERTICAL);

ImageView logo = new ImageView(context);
logo.setImageResource(R.drawable.whatever);
logo.setId(0);
addView(logo, lp);

lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.LEFT_OF, 0);
lp.addRule(RelativeLayout.CENTER_VERTICAL);

TextView header = new TextView(context);
header.setText("Lorem ipsum dolor sit amet.  Lorem ipsum dolor sit amet.  Lorem ipsum dolor sit amet.");
addView(header, lp);

I’d very much prefer to do this programmatically (as opposed to XML), for reasons too long and uninteresting to mention.

Any insight would be appreciated. TYIA.

  • 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-30T04:28:30+00:00Added an answer on May 30, 2026 at 4:28 am

    Don’t set your logoId to 0.
    Use setId(1231231) instead or ID number something like that and do it like
    lp.addRule(RelativeLayout.LEFT_OF, logo.getId()); you can also use setMargins(...) if you need them.


    Cheers

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

Sidebar

Related Questions

Should be pretty simple: I have an InputStream where I want to peek at
I have some pretty simple html which is meant to make a layout as
This one should be pretty simple. The use case is that I have a
I have a pretty simple css layout for a plate of information, you can
I have a pretty simple directory layout for my Maven/Eclipse project: . ├── pom.xml
i have pretty simple simple question (i hope so). How do i change the
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a pretty simple Linq to XML query: var q = from c
I have a pretty simple SQL I need to perform. I have a ProcessUser
I have a pretty simple question which perhaps someone familiar with Server/Client design &

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.