Reputation: 468
For an application that I'm working on, I have an editText that I allow users to input data into. I have defined padding on the input that is not maintained when multiple lines of text are entered in. For example:
After adding a second line of text:
As more and more lines are added, I'm also seeing that the position of the edittext in the parent view gets lower and lower:
My XML for the editText is as follows:
<EditText
android:id="@+id/message_edit"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/someBackground"
android:paddingLeft="@dimen/dp_12"
android:paddingRight="@dimen/dp_3"
android:elevation="3dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Type here"
android:lineSpacingExtra="@dimen/dp_4"
android:textColor="@color/black"
android:textSize="@dimen/sp_17" />
I assume that both issues are related given but i'm not sure what the underlying cause is.
Upvotes: 0
Views: 122
Reputation: 15423
Instead android:paddingLeft
and android:paddingRight
use only android:padding
to add padding
on all side. Check below:
<EditText
android:id="@+id/message_edit"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/someBackground"
android:padding="@dimen/dp_12"
android:elevation="3dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Type here"
android:lineSpacingExtra="@dimen/dp_4"
android:textColor="@color/black"
android:textSize="@dimen/sp_17" />
Result:
Upvotes: 1