EditText setError messed up on Samsung phones - android

So currently only reproducible on a Samsung S5 and a Galaxy note, this is what my EditText setError is
The thing is, I've tried setError on an empty application with an EditText field and it works 100% fine, so it's nothing that Samsung is intrinsically messing up with their libraries. But it does seem like it has to do with how they render their views? I've tested it on a Moto X and other non-samsung phones (including nexus 7 tablet) and it works fine!
When I click away and then back into the EditText, it then "messes" up again to this:
However, when I click and open the keyboard, rotate the screen into landscape, then back into portrait with the keyboard still up, the setError comes back to normal like so:
So I'm thinking it has to do with how we render our views or some boundary somewhere. I've already tried requestLayout(), forceLayout(), and invalidate() the view on edittext. Also tried invalidate() on the whole view. Still nothing. Any ideas/where to investigate? Thanks all
EDIT: Here's the XML Layout for the just the LinearLayout stuff
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5"
android:gravity="center"
android:paddingTop="#dimen/location_padding_top"
android:paddingBottom="100dp"
>
<EditText
android:id="#+id/location"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="Zip Code"
android:maxLength="5"
android:textSize="#dimen/field_text_size"
android:layout_weight="2"
/>
<ImageView
android:id="#+id/my_location_image"
android:src="#drawable/ic_menu_gps_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

Related

Popup of AutoCompleteTextView is showing behind keyboard

I have an AutoCompleteTextView in my app, at the bottom of the layout.
When user inputs data, suggestion popup with items should appear.
All works as expected on Android Samsung device with OS 6.0.1:
But for Android 8.0.0 (LG device and also an emulator 8.1.0), I don't see such popup, I suppose it showing behind keyboard for some reason (Because when I clicked back button nothing happened - popup handled that event, and only on second back click keyboard disappeared):
My AutocompleteTextview:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout ...
<android.support.v7.widget.AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="#drawable/thin_square_border"
android:maxLines="3"
android:minHeight="60sp"
android:padding="12dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:textColor="#color/charcoalgray"
/>
</LinearLayout>
</ScrollView>
I've tried dropDownAnchor on view above, and android:dropDownHeight="wrap_content" but that didn't help.
I found this solution that works for me in Oreo and Pie.
I added this to my fragment:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
This seems like a bug introduced in Oreo. Hope this helps for your case.
you have to set android:dropDownAnchor="#id/container_comment" in your autocomplete widget

UI of my app gets broken when testing on a phone [Android]

I am trying to do some simple app to practice, and the user interface gets broken for some reason I don't know why when I run test on my phone. I did an app on android only once before and I didn't have this problem, I was using a different phone though. I'm testing this on Samsung Galaxy A5.
That's how it looks in project: http://imgur.com/Pnbg5ns
And that's how it looks on my phone: http://imgur.com/a/uki84
Anyone knows how to resolve this?
All your views have locations set with the tools:... attribute. The locations set this way (using tools:) position the views within the Android Studio editor, and Android Studio editor only. It doesn't do anything at all to position the views for when the app is actually run, that's why all your views are on top of each other, they simply don't have any attributes to indicate their positioning on the screen when the app is run.
You should check tutorials for how to use ConstraintLayout (if you want to use that layout) which is a recent (2016) addition to Android and position your views with the constraints you need. Or you could use some of the older layouts like LinearLayout which should be perfectly fine for your layout needs.
And absolute positioning of the views like you have with the use of the tools:... attribute is also a big no most of the time. Views need to be positioned in some relative way within a layout, which doesn't mean it has to be within a RelativeLayout :), just saying that the views should be positioned in reference to the layout containing them, not just at some absolute point f.e. (150, 110).
This is a very simple layout. You can use LinearLayout instead of ConstraintLayout.
Here is an example using LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="16dp">
<EditText
android:id="#+id/etLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Login"
android:inputType="textPersonName" />
<EditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Hasło"
android:inputType="textPassword" />
<Button
android:id="#+id/bLogin"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Loguj"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="#+id/tvRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Nie masz jeszcze konta? Kliknij tutaj."
android:layout_gravity="center_horizontal"/>
</LinearLayout>
OUTPUT:
Hope this will help~

EditText sometimes randomly not showing?

So I have an app that has this EditText. With some devices (generally the ones with higher resolutions), the EditText tends to randomly not show. However, it can be solved by restarting the app.
Here's a picture of how it should be:
And here's a picture of how it sometimes it randomly disappears:
It is important to clarify that the disappearing doesn't happen while the app is running, when you open the app, the editText is either there or not.
Thank you so much!
This is the XML for the EditText:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal|numberSigned"
android:ems="10"
android:id="#+id/abs"
android:editable="true"
android:numeric="decimal"
android:textAlignment="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_alignLeft="#+id/btn"
android:layout_alignStart="#+id/btn"
android:layout_alignRight="#+id/btn"
android:layout_alignEnd="#+id/btn" />
android:layout_width="wrap_content"
The above line mean EditText will have same width as the size of text inside it. When EditText is empty it will be so small that you can't see.
You can fix this making EditText width same as its parent
android:layout_width="match_parent"
or you can fix width by providing your own width:
android:layout_width="80dp"

Right-align text in a TextView

I have some RTL text (Hebrew) that I want to be aligned right inside the TextView. Currently the XML looks like this:
<TextView
android:id="#+id/textView2"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:paddingRight="10dp"
android:singleLine="false"
android:textColor="#FFFFFF"
android:textDirection="rtl"
android:textSize="12sp"
android:textStyle="bold" />
And it acually works great on Galaxy S3 Android 4.2.2 and I even tested it on a Galaxy S1 Android 2.3.3 and it was ok too. But on some devices, for example Galaxy S2 Android 2.3.5, it's aligned left for some reason.
I searched alot and I did not find and solution to this problem, I'd be happy if someone will show me a solution within the XML layout file, but programatcly solution can work as well.
I tired with your code.. you want to placed the text in right side of textview right?...
I'm pretty to help you because, I also gone through this issue..
In your code,
android:gravity="right"
Instead of this, try this
android:gravity="end"
I think this is what you are looking for

EditText not updating with soft keyboard on QVGA devices

I'm having a problem with an EditText (only on QVGA devices, I've tested it on the QVGA emulator and on a Samsung i5500).
When the user clicks on the EditText and the soft keyboard comes up, only the first letter that the user enters appears on the field. The others only show up when the user closes the keyboard or some other event happens.
I don't know if this is a bug (it works on the higher res emulator), but is there any workaround I can use to give a better experience to my users right now?
My (messy) code is here:
https://github.com/bani/SMS-Denuncia/tree/master/android/
And the EditText I'm having a problem with is at
https://github.com/bani/SMS-Denuncia/blob/master/android/res/layout/local.xml
<EditText android:id="#+id/vagao2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="12"
android:textSize="18sp"
android:text=""
android:imeOptions="actionSend"
android:visibility="invisible" />
Somehow it got fixed when I surrounded my layout with ScrollView.

Categories

Resources