I am building a layout where text is displayed in a TextView.
When the user taps on the text, I want to display an EditText widget to
allow for the text to be modified.

I use a relative layout to ensure have the two widgets in the same position.
The edit text is declared first and then the the TextView is made to align
to the top and bottom of the EditText.

However, I have seen that the text displayed in the EditText is offset down
and to the left.
I need to ensure that, for the user, the text does not appear to move at
all when "switching" to the EditText.

Do I need to use padding values to align the text displays ?
If I do, is this guaranteed to work on all displays ?

Here is the relevant part of my layout :

     <RelativeLayout
         android:layout_width="0dp"
         android:layout_height="match_parent"
         android:layout_weight="1"
         android:paddingTop="15dp"
         android:paddingLeft="20dp">

         <EditText
             android:id="@+id/etListName"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
             android:layout_alignParentLeft="true"
             android:visibility="visible"
             android:textAppearance="?android:attr/textAppearanceLarge"
             android:text="List name" />

         <TextView
             android:id="@+id/tvListName"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignTop="@+id/etListName"
             android:layout_alignBottom="@+id/etListName"
             android:layout_alignParentLeft="true"
             android:textAppearance="?android:attr/textAppearanceLarge"
             android:visibility="visible"
             android:text="List name" />

     </RelativeLayout>


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Yaturner at Mar 27, 2014 at 11:24 pm
    Try wrapping both views in a FrameLayout. That should guarantee that they both occupy the same space

    --
    You received this message because you are subscribed to the Google
    Groups "Android Developers" group.
    To post to this group, send email to android-developers@googlegroups.com
    To unsubscribe from this group, send email to
    android-developers+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/android-developers?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Android Developers" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Simon Giddings at Mar 28, 2014 at 7:45 am
    I agree, in the same way as using the relative alignments above.
    However, as I stated, the displayed text is *not* at the same position -
    the EditText widget is higer and so there are offsets applied to the
    beginning of the text.

    On Friday, 28 March 2014 00:21:52 UTC+1, yaturner wrote:

    Try wrapping both views in a FrameLayout. That should guarantee that they
    both occupy the same space
    --
    You received this message because you are subscribed to the Google
    Groups "Android Developers" group.
    To post to this group, send email to android-developers@googlegroups.com
    To unsubscribe from this group, send email to
    android-developers+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/android-developers?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Android Developers" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-developers @
categoriesandroid
postedMar 26, '14 at 3:47p
activeMar 28, '14 at 7:45a
posts3
users2
websiteandroid.com

2 users in discussion

Simon Giddings: 2 posts Yaturner: 1 post

People

Translate

site design / logo © 2019 Grokbase