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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:54:37+00:00 2026-05-27T20:54:37+00:00

I have two relative layouts that are currently displayed one below the other. I

  • 0

I have two relative layouts that are currently displayed one below the other. I want the second layout to be displayed to right of the first relative layout programatically.

following is the code i used.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <RelativeLayout 
         android:layout_width="620dp"
         android:layout_height="wrap_content"
         android:orientation="vertical"
         android:id="@+id/lay1" >    
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/hello1" />
    </RelativeLayout>
    <RelativeLayout 
         android:layout_width="620dp"
         android:layout_height="wrap_content"
         android:orientation="vertical" 
         android:id="@+id/lay2">  
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/hello2" />
    </RelativeLayout>
</LinearLayout>

myAct.java

public class myAct extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LinearLayout layoutContainer = new LinearLayout(this);
        layoutContainer.setLayoutParams(new     LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        // Arguments here: width, height, weight 
        LinearLayout.LayoutParams childLp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
        RelativeLayout layoutLeft = new RelativeLayout(this);

        layoutContainer.addView(layoutLeft, childLp);
        RelativeLayout layoutRight = new RelativeLayout(this);
        layoutContainer.addView(layoutRight, childLp);
     }
}

Thanks in advance

  • 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-27T20:54:37+00:00Added an answer on May 27, 2026 at 8:54 pm

    Change your linear layout orientation to horizontal. I would also set a weight sum of the linear layout to 2, and give each relative layout a weight of 1 to make sure evenly split.

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

Sidebar

Related Questions

Right now, I have a layout that looks like one of the two images
I have an Activity with two layouts, both implemented in R.layout.main. The first one
I have got relative layout, in that i have placed two textviews, one image
I created one linear layout and I have added two relative layout. I wish
I have two relative layouts together, and I want to set an Image (drawable
I have two cases with Linear (also tried Relative) layout in android. The one
I have a layout with two images: one that should strech to the screen
I have a RelativeLayout , and this Layout has two childs, one is a
I currently have a two column layout with a header and a footer, the
I have two UILabels in a XIB file, one on top of the other,

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.