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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:23:38+00:00 2026-05-23T01:23:38+00:00

I have two EditText views whose height I wish to align. The problem is

  • 0

I have two EditText views whose height I wish to align. The problem is that I cannot predict which view will have more text and hence using android:layout_alignTop and android:layout_alignBottom will not work. The layout I am experimenting with is below. I have already tried android:layout_alignTop and android:layoutAlignBottom but they do not yield satisfactory results.

Layout 1

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

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent">

<EditText
        android:id="@+id/text1" 
        android:layout_width="200dip"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"           
        android:padding="5dip"

        android:text="Text 1 bvhg hbjbj kjkbkj kjnjkn hlihj lklkkl"
        />

<EditText
        android:id="@+id/text2" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/text1"           
        android:padding="5dip"

        android:text="Text 2 lasndklsa lkmsclslk klmsldmlk lksdl"
        />


</RelativeLayout>

Figure for Layout 1: https://i.stack.imgur.com/RcCGu.jpg.png

Layout 2 with android:layout_alignTop and android:layout_alignBottom

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

<EditText
        android:id="@+id/text1" 
        android:layout_width="200dip"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"   
        android:layout_alignTop="@+id/text2"
        android:layout_alignBottom="@+id/text2"

        android:padding="5dip"

        android:text="Text 1 bvhg hbjbj kjkbkj kjnjkn hlihj lklkkl"
        />

<EditText
        android:id="@+id/text2" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/text1"           
        android:padding="5dip"

        android:text="Text 2 lasndklsa lkmsclslk klmsldmlk lksdl"
        />


</RelativeLayout>

Figure for Layout 2: https://i.stack.imgur.com/FQtmj.jpg.png

But, if I were to change the text on the first EditText then some of the text in that box gets cut-off. See Layout 3 and Figure 3 below:

Layout 3

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

<EditText
        android:id="@+id/text1" 
        android:layout_width="200dip"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"   
        android:layout_alignTop="@+id/text2"
        android:layout_alignBottom="@+id/text2"

        android:padding="5dip"

        android:text="Text 1 bvhg hbjbj kjkbkj kjnjkn hlihj lklkkl
                    1 bvhg hbjbj kjkbkj kjnjkn hlihj lklkkl    ncksjcksn
                    lkslksldcsdc
                    the end"
        />

<EditText
        android:id="@+id/text2" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/text1"           
        android:padding="5dip"

        android:text="Text 2 lasndklsa lkmsclslk klmsldmlk lksdl"
        />


</RelativeLayout>

Figure 3 for Layout 3 : (Sorry, cannot post more than two hyperlinks because of rep issues.)

Is there a way to align the heights of EditText views when the amount of text in either view is not known ahead of time?

  • 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-23T01:23:39+00:00Added an answer on May 23, 2026 at 1:23 am

    Well, I have to say, this is the first time I’ve ever found a TableLayout useful. Note the text LOOKS cut off in the preview (as it’s really big), but when you compile and run, you’ll see that the text is scrollable. The TableView does all the tricky stuff for you. I think this will work for you.
    Just realised that you want the textviews to look the same size also – that’s easy – give them a transparent background and make the background of the table have the background.
    EDIT – One more thing – due to a framework bug, I had to use this:

    android:inputType="none"
    android:editable="false"
    

    to get the text both scrollable and non-editable. Also, a good point from @mandel – use “fill_parent” not “match_parent” if programming for android devices of an api level less than 8.

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <TableRow
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:id="@+id/tableRow1"
            android:gravity="center_vertical">
            <EditText
                android:inputType="none"
                android:editable="false"
                android:text="I have two EditText to align. The problem is that I cannot predict which view will have more tetText to align. The problem is that I cannot predict which view will have more text and hencem  I have two EditText views whose height I wish to align. The problem is that I cannot predict which view will have more text and hence"
                android:id="@+id/editText1"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">
            </EditText>
            <EditText
                android:inputType="none"
                android:editable="false"
                android:text="I have two EditText views whose height I wish to alignhave more text and hence "
                android:id="@+id/editText2"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"></EditText>
        </TableRow>
    </TableLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In one of my views, I have three EditText fields. The first two are
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have two applications written in Java that communicate with each other using XML
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have a textview in which i append text in two ways: First way:
I have two EditText and one Button in my Layout. If the two EditText
I have four EditText and two buttons namely, save and review button. If i
hello I have the following win32 program, and I have an EDITTEXT control that
I'm following this tutorial: http://developer.android.com/resources/tutorials/views/hello-datepicker.html . I have two EditText, and which one calls
I have a linearlayout in which i have one image view, one textview ,

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.