Android wrap_content does not wrap



Newbie Android programmer here. I'm making a xml layout with an EditText whose width should change to fit the text inside--text can be changed either by the user or programatically. I find that when the text exceeds 4 characters, the EditText stops expanding and keeps the excess characters offscreen. Here is my code:



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.appname.MainActivity" >

<EditText
android:id="@+id/textview1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_above="@+id/seekbar1"
android:layout_alignLeft="@+id/textview2"
android:ems="10"
android:imeActionLabel="Done"
android:imeOptions="actionDone"
android:inputType="phone"
android:text="@string/NaN" />

//Other objects...

</RelativeLayout>


Reading the documentation on wrap_content, I thought it would do what I wanted. Am I mistaken? Thanks for the help!


No comments:

Post a Comment