I am creating three EditText
s in my xml file using code like this:
<EditText android:id="@+id/name_edit_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/profile_image_view_layout" android:layout_centerHorizontal="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="20dp" android:ems="15" android:hint="@string/name_field" android:inputType="text" />
When I run the app, it looks like this on my device:
But I want it to look like this, without using any background image:
So how can that be done? Any ideas or suggestions will be helpful.
You can use EditText. setText(...) to set the current text of an EditText field.
You can use the attribute style="@style/your_style" that is defined for any widget. The attribute parent="@android:style/Widget. EditText" is important because it will ensure that the style being defined extends the basic Android EditText style, thus only properties different from the default style need to be defined.
How to include a Edittext in an Android App: First of all, create a new Android app, or take an existing app to edit it. In both the case, there must be an XML layout activity file and a Java class file linked to this activity. Open the Activity file and include a Edittext field in the layout (activity_main.
If you want your disabled EditText to look the same as your enabled one, you should use android:enabled="false" in combination with android:textColor="..." . Show activity on this post. Used this if you have an icon to be clickable, this works for me.
Create xml file like edit_text_design.xml and save it to your drawable folder
i have given the Color codes According to my Choice, Please Change Color Codes As per your Choice !
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <solid android:color="#c2c2c2" /> </shape> </item> <!-- main color --> <item android:bottom="1.5dp" android:left="1.5dp" android:right="1.5dp"> <shape> <solid android:color="#000" /> </shape> </item> <!-- draw another block to cut-off the left and right bars --> <item android:bottom="5.0dp"> <shape> <solid android:color="#000" /> </shape> </item> </layer-list>
your Edit Text Should contain it as Background :
add android:background="@drawable/edit_text_design" to all of your EditText's
and your above EditText should now look like this:
<EditText android:id="@+id/name_edit_text" android:background="@drawable/edit_text_design" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/profile_image_view_layout" android:layout_centerHorizontal="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="20dp" android:ems="15" android:hint="@string/name_field" android:inputType="text" />
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