EditText set text start 10dp from left border
Is possible in android EditText widget to set that text start 10dp from left border ? When I type something at the moment it is glued to left side and I need to put a little padding.
This can be achieved with the android:padding
attribute.
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
has a 10dp padding on all sides
you may just want to specify the left and right padding.
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
Will make the padding on the left and right be 10dp.
Use paddingStart (and paddingEnd)
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10pt"
android:textColor="#646464"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:maxLines="1"
android:ellipsize="end"
/>
Did this really solve your problem? setting padding on xml doesn't seem to apply on EditText for me. I solved it some other way. Placed the EditText in side a RelativeLayout view and applied the padding to that RelativeLayout.
<RelativeLayout
android:layout_width="258dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:paddingLeft="5dp"
android:background="@drawable/textbox_bg">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/emailText"
android:text="text inside"
android:inputType="textEmailAddress"
android:background="@android:color/transparent" />
</RelativeLayout>
as i had issues with EditText background RelativeLayout and set the EditText background transparent. Hope this helps