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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:24:03+00:00 2026-06-04T22:24:03+00:00

I have a vertical linearlayout, it has inside two linearlayout with diferent elements, I

  • 0

I have a vertical linearlayout, it has inside two linearlayout with diferent elements, I would like to fix the first one to the top, and the second one centered, I’m trying it but doesn’t work:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_bg"
    >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:background="#3b5998"
    >    
         elements
    </LinearLayout>


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="300dip"
        android:layout_height="300dip"
        android:background="@drawable/background_resto"
        android:gravity="center"
    >

           elements
    </LinearLayout>
    </LinearLayout

Why is it not working? Thank you 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-06-04T22:24:05+00:00Added an answer on June 4, 2026 at 10:24 pm

    I’d advice to choose a RelativeLayout for that purpose.

    <?xml version="1.0" encoding="utf-8"?>
    

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/holo_blue_bright"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:layout_alignParentTop="true"
            android:background="#fff" >
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="300dip"
            android:layout_height="300dip"
            android:layout_centerInParent="true"
            android:background="@android:color/holo_green_light"
            android:orientation="vertical" >
        </LinearLayout>
    </RelativeLayout>
    

    This will help you to set the exact “relative” position in relation to other views.

    Best wishes,
    Tim

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

Sidebar

Related Questions

This has puzzled me for two days now. I have a LinearLayout like the
I have a vertical LinearLayout which has a list view and one ImageView at
I have a vertical StackPanel with two elements: a Button and a ListBox. How
I have a layout with two ImageView inside. Each image has a fixed aspect
I have a LinearLayout that has 3 layouts at the top. (So the grey
So I'm trying to put a LinearLayout that has two TextViews inside of a
I have two views (ads) and when one ad network has no ad to
I have a vertical NSSplitView containing on one of its sides a NSScrollView with
I have a HTML which has lot of content and a vertical scrollbar appears
So I have an Activity which has a FragmentPagerAdapter and inside each fragment I

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.