EditText numberDecimal but keyboard appears - android

I'm trying to use an EditText to only receive decimals, and it work's, but only in android emulator. In my Xiaomi (MIUI optimization disabled), the first time I click on it, normal keyboard appears (but I can't write anything), and the second time, numeric keyboard appears and now I'm able to use it the right way.
This is the code for the EditText:
<EditText
android:id="#+id/et_cambio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:digits="0123456789."
android:inputType="numberDecimal"
android:textAlignment="center" />
Any thoughts on what can be happening?
Thank you so much :)

Try putting this line in your Manifest for Activity where you have EditText
<activity
android:windowSoftInputMode="stateHidden|adjustNothing">
</activity>

Related

Lower TextInputEditText not displaying text while typing, only displayed after done (or) next action (or) when tapping anywhere in screen

Below is my code for EditText,
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/password_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/username_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:hintEnabled="false"
app:passwordToggleEnabled="false"
app:passwordToggleTint="#color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login_username_input"
android:layout_weight="0.0"
android:drawableEnd="#drawable/password"
android:background="#drawable/round_bg"
android:hint="#string/login_password_hint"
android:imeActionLabel="#string/action_done"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="#+id/submit_btn"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textCursorDrawable="#null"
tools:ignore="RtlSymmetry" />
</com.google.android.material.textfield.TextInputLayout>
I am setting password eye icon programatically like below,
passwordLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
passwordLayout.setEndIconDrawable(GetDrawable.getDrawable("Show/Hide Password"));
passwordLayout.setEndIconTintList(ColorStateList.valueOf(getResources().getColor(R.color.color_white)));
This works fine in most of the devices. But getting below issue in Mi a2 Android Version 10.
I have two TextInputLayout for user name and password field
There is no issue while typing username field.
Next moved to password field. Now, the cursor stucked in first position and typing text is showed up in keyboard but not displayed in Edittext field. Only text is displayed after tapping somewhere else in screen
I am not sure why this happens in some devices
Found below question related to my issue. But no solution provided there.
TextInputEditText is not showing the typed text/number when typing
UPDATE
In this given a solution for my issue, Android Pie edittext does not adjustPan/resize while typing but using Hardware acceleration may lead to high memory usage. So afraid to use this solution.
is there any other way to solve this?
I tested the code on emulator on two android devices find nothing wrong with it used com.google.android.material:material:1.3.0
please update your color style it has no Legiblity
pan Adjuesment related issued loged in debug check that
try alpha or Rc MDC for libaray version bug
Finally you do is open issue at MDC github here

Stop Decimal EditText from gaining focus on startup

I have followed this solution on preventing edit text from taking focus on activity startup. And implemented it as such
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/amount"
android:text="#string/zero"
android:gravity="end|center_vertical"
android:nextFocusUp="#id/amount"
android:nextFocusLeft="#id/amount"
android:inputType="numberDecimal"/>
Notice the android:inputType="numberDecimal". If I remove that then upon startup the focus is not taken, however if it is there then focus is taken. Is there any way to get decimal edit text to not take focus upon startup? I am using API > 23 if it is of any concern.
And just as a side note from looking at answers other people provided to similar questions, I want my field to not take focus. I do not want to only hide the soft keyboard but keep the focus.
Add this to your activity tag in manifest
android:windowSoftInputMode="stateHidden|adjustResize"
Code looks like in manifest
<activity
android:name=".ActivityName"
android:windowSoftInputMode="stateHidden|adjustResize" />
This will help hide soft keyboard at startup
And add these tags to your root layout rather than parent layout
android:focusable="true"
android:focusableInTouchMode="true"

Double cursor in EditText for Input Type Number/Phone (RTL Arabic)

I have an EditText set to gravity Right, so that the text starts from the right if the language is Arabic.
Note: My application supports RTL, and I am not setting the TextDirection for my EditText as that will have the same problem. Gravity set to Right does the job perfectly. I have an issue only if I set the InputType to Number or Phone.
If the InputType is set to number/phone there are double cursor at the beginning and end of the text and it is a bit confusing.
To demonstrate this, I have two EditText with InputType Text and Number, Gravity set to Right for both. My application supports RTL and My phone is now set to Arabic language
Manifest
android:supportsRtl="true"
XML
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="text"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:gravity="right"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/phone"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:gravity="right"
/>
Here is a screen shot of the behaviour for the second EditText with InputType Number.
Any pointers on how to get rid of the double cursor? or any alternative.
Thanks
R
Use properties layout_direction as 'ltr' and gravity 'right'.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/phone"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:gravity="right" />
This solved my problem.
The Edit text doesn't know if the next char you will press is a number or a letter so in case of a letter it places the far left one while the far right one for a number(Most likely you know that just making sure).
So it will disappear if you switch to English.
I think this is fundamental in the edit text:
Solutions:
1- You can create your own edit text from scratch(From View).(May take month with all the problems that may arise).
2- Find a way to override the edit text to remove the split.
3- Find a git where someone had solved that problem(which I doubt).
This doesn't seem like a problem as a programmer or a user. A designer maybe will be a bit annoyed but ignoring it is the fastest way.
Sorry if this wasn't usefull.
ViewCompat.setLayoutDirection(findViewById(R.id.myedittext), ViewCompat.LAYOUT_DIRECTION_LTR);
it worked for me.
wrap your edittext in linearlayout with horizontal oriation and layoutDirection ltr
try to change android:inputType="number" into phone..
for example :
<com.test.utils.custom.CustomTelephone
android:id="#+id/custom_telephone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="phone"
android:text="#string/telephone_number_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/iv_logo" />
that worked for me ..
if not work try to add layoutDirection:Rtl in edit Text as attribute ..
Happy coding .. !

android editText multiline return to line not working with swiftkey

I have the following edit text
<EditText
android:id="#+id/txtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:gravity="start"
android:inputType="text|textMultiLine"
android:minHeight="90dp"
android:singleLine="false"
android:textColor="#color/textColor" />
Every reference shows that the code is correct and in fact the text wraps to multiline. But the enter key doesn't go to the new line when i use swiftkey keyboard (Google keyboard works fine)
any idea of how to solve this issue ?
Thanks
Have you considered switching to the default keyboard. It might solve your issue.
See this answer Set EditText to be Multiline(Enter is carrige return) and not display suggestions for more details.

AutoCompleteTextview singleLine setText() with text longer than view size will cause broken words

I have the following AutoCompleteTextView :
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
The input to this AutoCompleteTextView is done via a "Dialer" Layout I've created , thus this AutoCompleteTextView is android:enabled="false" and in order to add the user input on my AutoCompleteTextView I use the following code :
String mText =_searchAutoCompleteTextView.getText().toString()+_dialer_digits[position]; //the digit the user clicked upon
_searchAutoCompleteTextView.setText(mText);
_searchAutoCompleteTextView.performCompletion();
if(_searchAutoCompleteTextView.getText().toString().length()>2 && _searchAutoCompleteTextView.getAdapter().getCount()> 0)
{
_searchAutoCompleteTextView.showDropDown();
}
Every thing is working fine except a weird issue :
Since the input is not done by the device's keyboard and only by my dialer with setText() , if the user clicks alot of digits whihc are longer than the AutoCompleteTextView's size last digit is broken and while continuing to input more digits the AutoCompleteTextView does not scroll left. The weird thing about it is that I've tried to enable it and put some long input from the device's keyboard it works perfectly , long text is not broken and scrolling is happening. Since I cannot use the device's keyboard it must be done via my layout and setText()
Many thanks ahead
EDIT:
here is a screen shot :
You can use append instead of setText to move the cursor to the end.
I'm not sure if this will work but have you tried to put your AutoCompleteTextView in a HorizontalScrollView?
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
</HorizontalScrollView>
Can you provide a screen shot so I can better understand the issue you are having?
You need to set Gravity of AutocompleteTextVIew to right:
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:gravity="right"
android:textSize="20sp" >
</AutoCompleteTextView>

Categories

Resources