Saturday, 26 October 2019

EditText disapears when clicked after fragment transaction

my EditText works perfectly fine, until you open another fragment and return back to the first one. After clicking the EditText the keyboard pops up and it looks like the soft-keyboard is pushing the content of the fragment upwards and behind the background image.

This looks something like this:

before

And after you opended a fragment and closed it again:

after

My Search Text View:

<EditText
                android:id="@+id/search_view"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginStart="30dp"
                android:layout_marginEnd="30dp"
                android:background="@drawable/textfield"
                android:digits="@string/digits"
                android:drawableStart="@drawable/ic_search"
                android:drawablePadding="10dp"
                android:fontFamily="@font/opensans_normal"
                android:hint="@string/search"
                android:inputType="text"
                android:paddingStart="10dp"
                android:paddingEnd="10dp"
                android:singleLine="true"
                android:textColor="@color/colorFont"
                android:textColorHint="@color/colorFont"
                android:textSize="15sp" />

When this method gets called the bug happens:

  fun addFilter() {
    val topicList = mutableListOf<Topic?>()
    topicAdapter = TopicAdapter(topicList, context, null, true)

    if (CachedData.filter.isNotEmpty()) {

        if (CachedData.filter[0] != null) {
            filterList.visibility = View.VISIBLE
            topicList.add(Topic(CachedData.filter[0], selected = true, clickable = true))
        }

        if (CachedData.filter[1] != null) {
            filterList.visibility = View.VISIBLE
            if (CachedData.filter[0] == null) {
                topicAdapter.setSubselect(-1)
            }
            topicList.add(Topic(CachedData.filter[1], selected = true, clickable = true))
        }
    }
    filterList.adapter = topicAdapter
    filterList.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
}


from EditText disapears when clicked after fragment transaction

No comments:

Post a Comment