The default EditText background seems to put ~ 4dp of padding on the left. This causes misalignment with other widgets.
I made a simple app to demonstrate. Screenshot:
Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".MainActivity"> <TextView android:background="#00ff00" android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="HINT" android:text="TEXT" android:singleLine="true"/> <TextView android:background="#00ff00" android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
Is there anyway to stop it from doing this?
By default, some space is reserved for assistive labels below SfTextInputLayout control. These reserved spaces can be removed by setting ReserveSpaceForAssistiveLabels property as false when helper and error text are empty and ShowCharCount is false.
The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific number of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge.
In your xml code set focusable="false" , android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.
One workaround is to use negative margin on the sides (-4dp)
This will only work when the EditText background matches the Layout background, and you don't have anything on the sides in the Layout that would be covered by the EditText
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With