brf42
brf42

Reputation: 151

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:

How it should be

And here's a picture of how it sometimes it randomly disappears:

Disappeared

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" />

Upvotes: 1

Views: 69

Answers (1)

Sharjeel
Sharjeel

Reputation: 15798

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"

Upvotes: 1

Related Questions