I want to make drawable and text center in my EditText. The text is centered but the drawable is not. I want something like this: http://i.imgur.com/cacxR2C.jpg?1
Please help. This is what I have done so far
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:drawableLeft="@drawable/lol2"
/>
When the user types in something in the EditText, the drawable should move itself to the left if the text is lenghty.
You can do something like this
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@android:drawable/editbox_background"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Username"
android:background="@null"
android:gravity="center"
android:drawableLeft="@drawable/ic_launcher"
/>
</RelativeLayout>
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