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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:04:29+00:00 2026-05-26T14:04:29+00:00

I need a box within a box, with ~33% of empty room at the

  • 0

I need a box within a box, with ~33% of empty room at the top of the first box, and then another box below that. I need it to be centered. I would like this to essentially fill_parent on a mobile phone, but on a tablet (the primary device for this app), it should remain the same size but be centered in the middle of the screen. How can I do this?

I’m including to examples since it’s a little hard for me to explain.

Mobile

|---------------------------|
|     ~33% Blank space      |
|                           |
|  |---------------------|  |
|  |                     |  |
|  |                     |  |
|  |      Login Box      |  |
|  |      Password       |  |
|  |                     |  |
|  |                     |  |
|  |                     |  |
|  |                     |  |
|  |                     |  |
|  |---------------------|  |
|---------------------------| 

Tablet

|---------------------------------------|
|           ~33% Blank space            |
|                                       |
|        |---------------------|        |
|        |                     |        |
|        |                     |        |
|        |      Login Box      |        |
|        |      Password       |        |
|        |                     |        |
|        |                     |        |
|        |                     |        |
|        |                     |        |
|        |                     |        |
|        |---------------------|        |
|---------------------------------------| 

Edit Here is the XML I currently have. I’m not getting intellisense for anything, (I usually get suggestions), and I’m getting a cast exception with multiple layouts. Is there something wrong with the XML?

<?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"
    android:weightSum="1"
    >
    <LinearLayout android:id="@+id/topSpacer"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".33"
        android:orientation="horizontal"
        ></LinearLayout>
    <LinearLayout
        android:id="@+id/bottomSection"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".67"
        android:orientation="horizontal"
        >
        <LinearLayout
            android:id="@+id/loginSection"
            android:layout_width="320dip"
            android:layout_height="fill_parent"
            android:background="#FFFFFF"
            >
            <TextView
                android:text="" 
                android:id="@+id/errorMessage" 
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent" 
            />
            <TextView 
                android:text="Please login using your active directory credentials." 
                android:id="@+id/loginMessage" 
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent" 
            />
            <AutoCompleteTextView 
                android:id="@+id/loginUsername" 
                android:text="Username" 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
            />
            <EditText
                android:id="@+id/loginPassword"
                android:text="Password"
                android:password="true"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
            />
            <Button
                android:id="@+id/loginButton"
                android:text="Login"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
            />
            <TextView 
                android:text="results" 
                android:id="@+id/resultsMessage" 
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent" 
            />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
  • 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-26T14:04:30+00:00Added an answer on May 26, 2026 at 2:04 pm

    Try a combination of linear layouts that utilize the weightSum property. Also notice that the inner box’s width is fixed as you mentioned on the tablet you don’t want it to re-size.

    Try this:

    *EDIT: i used a relative layout to get the inner box centered *

    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"
      android:weightSum="1">
    <LinearLayout android:id="@+id/thirtyThreePercentSpacer" 
            android:layout_width="fill_parent" 
            android:orientation="horizontal"
            android:layout_height="0dp"
            android:layout_weight=".33">
    </LinearLayout>
    <RelativeLayout android:id="@+id/RelativeLayout01" 
        android:layout_width="fill_parent" 
        android:layout_height="0dp"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight=".67">
    
                <LinearLayout android:id="@+id/innerBox" 
                        android:layout_width="320dip" 
                        android:layout_height="fill_parent"
                        android:layout_centerInParent="true">
                </LinearLayout>
    
      </RelativeLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to vertically align images within a containing box like this: <span class=image-box><img src=/1_thumb.jpg></span>
Trying to keep a box centered vertically within another box. I know there's css
I have a box that is 950px wide. Within this box I want to
I need to control inbound and outbound traffic to/from a linux box from within
I need to implement a table in Qt that shows a Combo Box on
I am trying to create an application that contains a StyledText box displayed within
I am building a search box that queries a database and autofills suggestions below.
I have a dialog box that is: JOptionPane.showMessageDialog(null,Once medicine is given, measure temperature within
I'm creating a blog, but I need box-shadows for my boxes, so I'm asking
G'day, on a 64bit RHEL5 box we need to install our 32bit application. For

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.