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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:47:51+00:00 2026-05-24T04:47:51+00:00

I am building an app with a reusable numeric keyboard. The keyboard has been

  • 0

I am building an app with a reusable numeric keyboard. The keyboard has been placed in its own XML file so it can be included where needed throughout the app. I want to split the screen for the current activity into two pieces, the fixed size numeric keyboard at the bottom and a RelativeLayout (RL) above with the rest of the controls.

The problem is, the RL isn’t behaving itself. In the example below, the RL takes up the entire screen, and the keyboard does not show. The really strange thing is when I reverse the placement, place the include with the keyboard at the top, the screen displays as expected, with keyboard and RL each taking up roughly half.

In other words: when the keyboard is included at the top, all is fine (but the keyboard is in the wrong place); but when I include the keyboard at the bottom, the keyboard does not show and the RL takes up the entire screen.

Help! This kind of inconsistency drives me nuts and I am on the verge of hurling the computer across the room.

The activity’s XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/statsTabLayout"
    android:scaleType="fitXY"
    android:background="#ffffff" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:baselineAligned="true" 
    android:orientation="vertical">

    <RelativeLayout android:id="@+id/statsTopLayout"
        android:background="#ffffff" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:orientation="vertical">


    <TextView android:id="@+id/textViewTopMargin" 
        android:text="                              " 
        android:textColor="#FFFFFF"
        android:textSize = "5sp"
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_gravity="top"
        android:layout_alignParentLeft="true"
        android:paddingTop="0px"
    ></TextView>

    <TextView android:id="@+id/textViewAverage" 
        android:text="Average =    (%)" 
        android:textColor="#000000"
        android:textSize = "25sp"
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:paddingBottom="5px"
        android:layout_below="@+id/textViewTopMargin"
        android:layout_alignParentLeft="true"
    ></TextView>

    <Button android:id="@+id/buttonReset" 
        android:text="reset" 
        android:onClick="resetButtonClick" 
        android:textSize = "12sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignTop="@+id/textViewAverage" 
        android:layout_alignBottom="@+id/textViewAverage"
        android:layout_below="@+id/textViewTopMargin"
        android:layout_alignParentRight="true"
    ></Button>

    <TextView android:id="@+id/textViewHi" 
        android:text="High= " 
        android:textColor="#000000"
        android:textSize = "20sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="5px"
        android:layout_below="@+id/textViewAverage"
        android:layout_alignParentLeft="true"
    ></TextView>

    <TextView android:id="@+id/textViewLow" 
        android:text="Low= " 
        android:textColor="#000000"
        android:textSize = "20sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="5px"
        android:layout_below="@+id/textViewAverage"
        android:layout_centerHorizontal="true" 
    ></TextView>

    <TextView android:id="@+id/textViewMax" 
        android:text="Max= " 
        android:textColor="#000000"
        android:textSize = "20sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="5px"
        android:layout_below="@+id/textViewAverage"
        android:layout_alignParentRight="true"
    ></TextView>

    <TextView android:id="@+id/textViewScore" 
        android:text="Score = " 
        android:textColor="#000000" 
        android:textSize = "30sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="5px"
        android:layout_above="@+id/textViewScoreCalculation"
        android:layout_alignParentLeft="true"
    ></TextView>

    <TextView android:id="@+id/textViewScoreCalculation" 
        android:text="(score calculation)" 
        android:textColor="#000000"
        android:textSize = "20sp"
        android:textStyle="italic"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="10px"
        android:layout_above="@+id/editTextPoints"
        android:layout_alignParentRight="true"
    ></TextView>

    <TextView android:id="@+id/textViewPoints" 
        android:text="Enter Points: " 
        android:textSize = "30sp"
        android:textColor="#000000"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_above="@+id/textViewBottomMargin"
        android:layout_alignParentLeft="true"
        android:paddingBottom="10px"
    ></TextView>

    <EditText android:id="@+id/editTextPoints" 
        android:text="" 
        android:digits="-0123456789."
        android:windowSoftInputMode="stateVisible"
        android:focusable="true"
        android:textSize = "30sp"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignTop="@+id/textViewPoints" 
        android:layout_alignBottom="@+id/textViewPoints"
        android:layout_above="@+id/textViewBottomMargin"
        android:layout_toRightOf="@+id/textViewPoints" 
        android:paddingBottom="10px"
    ></EditText>

    <TextView android:id="@+id/textViewBottomMargin" 
        android:text="                              " 
        android:textColor="#FFFFFF"
        android:textSize = "5sp"
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true" 
        android:paddingBottom="0px"
    ></TextView>


    </RelativeLayout>


    <include layout="@layout/numerickeyboard" />

</LinearLayout>

The parent layout for the included keyboard:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="104pt" 
    android:id="@+id/numberPadLayoutContainer" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent"
    android:background="#404040"
    android:layout_alignParentBottom="true" 
>

Any suggestions?

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

    The problem is that some of the child layout attributes for RelativeLayout, such as layout_alignParentBottom="true", require that the layout decide its own dimensions before laying out the child that wants to align to its Bottom. In effect, when the child asks to alignParentBottom, it forces the RelativeLayout to use all the vertical space available to it.

    The last several items in your layout stack above the final element, TextView android:id="@+id/textViewBottomMargin", which is defined as alignParentBottom. I fixed the layout by modifying those last few elements to align below the previous items instead of aligning above the last item.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/statsTabLayout"
        android:scaleType="fitXY"
        android:background="#ffffff" 
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
        android:baselineAligned="true" 
        android:orientation="vertical">
    
        <RelativeLayout android:id="@+id/statsTopLayout"
            android:background="#ffffff" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:orientation="vertical">
    
    
        <TextView android:id="@+id/textViewTopMargin" 
            android:text="                              " 
            android:textColor="#FFFFFF"
            android:textSize = "5sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_gravity="top"
            android:layout_alignParentLeft="true"
            android:paddingTop="0px"
        ></TextView>
    
        <TextView android:id="@+id/textViewAverage" 
            android:text="Average =    (%)" 
            android:textColor="#000000"
            android:textSize = "25sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewTopMargin"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <Button android:id="@+id/buttonReset" 
            android:text="reset" 
            android:onClick="resetButtonClick" 
            android:textSize = "12sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_alignTop="@+id/textViewAverage" 
            android:layout_alignBottom="@+id/textViewAverage"
            android:layout_below="@+id/textViewTopMargin"
            android:layout_alignParentRight="true"
        ></Button>
    
        <TextView android:id="@+id/textViewHi" 
            android:text="High= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewLow" 
            android:text="Low= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_centerHorizontal="true" 
        ></TextView>
    
        <TextView android:id="@+id/textViewMax" 
            android:text="Max= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_alignParentRight="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewScore" 
            android:text="Score = " 
            android:textColor="#000000" 
            android:textSize = "30sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewHi"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewScoreCalculation" 
            android:text="(score calculation)" 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:textStyle="italic"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="10px"
            android:layout_below="@+id/textViewScore"
            android:layout_alignParentRight="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewPoints" 
            android:text="Enter Points: " 
            android:textSize = "30sp"
            android:textColor="#000000"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewScoreCalculation"
            android:layout_alignParentLeft="true"
            android:paddingBottom="10px"
        ></TextView>
    
        <EditText android:id="@+id/editTextPoints" 
            android:text="" 
            android:digits="-0123456789."
            android:windowSoftInputMode="stateVisible"
            android:focusable="true"
            android:textSize = "30sp"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignTop="@+id/textViewPoints" 
            android:layout_alignBottom="@+id/textViewPoints"
            android:layout_toRightOf="@+id/textViewPoints" 
            android:paddingBottom="10px"
        ></EditText>
    
        <TextView android:id="@+id/textViewBottomMargin" 
            android:text="                              " 
            android:textColor="#FFFFFF"
            android:textSize = "5sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/editTextPoints"
            android:paddingBottom="0px"
        ></TextView>
    
    
        </RelativeLayout>
    
    
        <include layout="@layout/numerickeyboard" />
    
    </LinearLayout>
    

    I also modified the keyboard by removing its android:layout_alignParentBottom="true" statement.

    This is the screenshot op an HVGA_1.6 emulator (I made your keyboard area green for the screenshot).

    enter image description here

    As per the amended question, “also want the statsTopLayout to fill the screen when we don’t include the keyboard” (see comments), I humbly submit these modifications to the original main and keyboard layout files:

    In the original main.xml, change the root LinearLayout to a RelativeLayout, then move the <include> to be its first element. In that moved <include> element, add the android:id="@+id/numberPadLayoutContainer" statement from numerickeyboard.xml (and remove it from numerickeyboard.xml (main.xml won’t compile without the local ID declaration). The third element is now the enclosed RelativeLayout, which now specifies layout_height="fill_parent" and layout_above="@id/numberPadLayoutContainer".

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/statsTabLayout"
        android:background="#ffffff" 
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
        >
    
        <include layout="@layout/numerickeyboard" 
                android:id="@+id/numberPadLayoutContainer" 
            />
    
        <RelativeLayout android:id="@+id/statsTopLayout"
            android:background="#ffffff" 
            android:layout_height="fill_parent" 
            android:layout_width="wrap_content" 
            android:layout_above="@id/numberPadLayoutContainer">
    
    
        <TextView android:id="@+id/textViewTopMargin" 
            android:text="                              " 
            android:textColor="#FFFFFF"
            android:textSize = "5sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_gravity="top"
            android:layout_alignParentLeft="true"
            android:paddingTop="0px"
        ></TextView>
    
        <TextView android:id="@+id/textViewAverage" 
            android:text="Average =    (%)" 
            android:textColor="#000000"
            android:textSize = "25sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewTopMargin"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <Button android:id="@+id/buttonReset" 
            android:text="reset" 
            android:onClick="resetButtonClick" 
            android:textSize = "12sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_alignTop="@+id/textViewAverage" 
            android:layout_alignBottom="@+id/textViewAverage"
            android:layout_below="@+id/textViewTopMargin"
            android:layout_alignParentRight="true"
        ></Button>
    
        <TextView android:id="@+id/textViewHi" 
            android:text="High= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewLow" 
            android:text="Low= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_centerHorizontal="true" 
        ></TextView>
    
        <TextView android:id="@+id/textViewMax" 
            android:text="Max= " 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_below="@+id/textViewAverage"
            android:layout_alignParentRight="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewScore" 
            android:text="Score = " 
            android:textColor="#000000" 
            android:textSize = "30sp"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="5px"
            android:layout_above="@+id/textViewScoreCalculation"
            android:layout_alignParentLeft="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewScoreCalculation" 
            android:text="(score calculation)" 
            android:textColor="#000000"
            android:textSize = "20sp"
            android:textStyle="italic"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:paddingBottom="10px"
            android:layout_above="@+id/editTextPoints"
            android:layout_alignParentRight="true"
        ></TextView>
    
        <TextView android:id="@+id/textViewPoints" 
            android:text="Enter Points: " 
            android:textSize = "30sp"
            android:textColor="#000000"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:layout_above="@+id/textViewBottomMargin"
            android:layout_alignParentLeft="true"
            android:paddingBottom="10px"
        ></TextView>
    
        <EditText android:id="@+id/editTextPoints" 
            android:text="" 
            android:digits="-0123456789."
            android:windowSoftInputMode="stateVisible"
            android:focusable="true"
            android:textSize = "30sp"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignTop="@+id/textViewPoints" 
            android:layout_alignBottom="@+id/textViewPoints"
            android:layout_above="@+id/textViewBottomMargin"
            android:layout_toRightOf="@+id/textViewPoints" 
            android:paddingBottom="10px"
        ></EditText>
    
        <TextView android:id="@+id/textViewBottomMargin" 
            android:text="                              " 
            android:textColor="#FFFFFF"
            android:textSize = "5sp"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true" 
            android:paddingBottom="0px"
        ></TextView>
        </RelativeLayout>
    </RelativeLayout>
    

    Screenshot with the <include> statement:

    enter image description here

    Screenshot without the <include> statement and without the android:layout_above="@id/numberPadLayoutContainer" statement:

    enter image description here

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

Sidebar

Related Questions

I've been building an app recently that has a model Books that is a
Am building an app using Django as my workhorse. All has been well so
I'm building an app that pulls data in from an excel .csv file and
I am building my own web app, and there are open source code out
Building an app using a calendar on a Google Apps domain that has SSL
I'm currently building an app in Appcelerator Titanium 1.2.1. I've been able to set
I am building an app that can track weight. I allow the user to
I'm not sure where to start with this, I've been building an app over
I am building app with php and jquery and it has many ajax loads
I'm building an app that authors would (hopefully) use to help them, uh.. author

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.