I am creating custom edit text in android by adding xml in drawable res.it is as following
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Border -->
<item>
<shape>
<solid android:color="@color/gray"></solid>
</shape>
</item>
<!-- Body -->
<item
android:bottom="1dp"
android:right="0dp"
android:left="0dp"
android:top="0dp">
<shape>
<solid android:color="@color/white"></solid>
</shape>
</item>
</layer-list>
<EditText
android:id="@+id/edt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/edittext"
android:digits="1234567890"
android:ellipsize="end"
android:focusableInTouchMode="true"
android:inputType="numberPassword"
android:singleLine="true"
android:textColor="@color/dark" />
so i just want edittext as a single line. But when i implement this, for few seconds the upper border of edittext is visible and then it goes away... I am really not getting why this is happening...
android:imeOptions="actionSend" /> You can then listen for presses on the action button by defining a TextView.OnEditorActionListener for the EditText element. In your listener, respond to the appropriate IME action ID defined in the EditorInfo class, such as IME_ACTION_SEND . For example: findViewById<EditText>(R.
AppCompatEditText widget enhanced with emoji capability by using EmojiEditTextHelper . A EditText which supports compatible features on older versions of the platform, including: Allows dynamic tint of its background via the background tint methods in androidx.
Create res/drawable/custom_edittext_style.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/apptheme_textfield_default_holo_light" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/apptheme_textfield_disabled_holo_light" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/apptheme_textfield_activated_holo_light" />
<item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/apptheme_textfield_focused_holo_light" />
<item android:state_enabled="true" android:drawable="@drawable/apptheme_textfield_default_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/apptheme_textfield_disabled_focused_holo_light" />
<item android:drawable="@drawable/apptheme_textfield_disabled_holo_light" />
And add all require drawable file into drawable folder.
<EditText
android:id="@+id/edt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/custom_edittext_style"
android:digits="1234567890"
android:ellipsize="end"
android:focusableInTouchMode="true"
android:inputType="numberPassword"
android:singleLine="true"
android:textColor="@color/dark" />
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