0

First I used custom Listview, when i set some content on edit text and select value from dropdown list and after scrolling listview I lost my text view and edit text contents.

Then I use Recyclerview. but same happens with recyclerview too. I again lost contents from textview and edittext.

1 Answers1

1

Are you talking about a FloatingActionButton, I guess?

It subclasses from ImageButton, so was not likely designed with text in mind, but rather, an image. An ImageButton in turn is also an ImageView.

Other Peoples' Solutions

So, you could look up how people have gone about adding text on top of those more common elements. Here are just a few topics on this very site, that came up quickly:

My Ideas

One of several approaches that come to mind would be to implement the FloatingActionButton's onDraw(Canvas canvas) method, and then call drawText() on the Canvas object it receives.

Another idea is to arrange to have a TextView shown on top of the FloatingActionButton.

Or, alternately, don't use FloatingActionButton, but something that more readily accepts text.

Jameson
  • 6,400
  • 6
  • 32
  • 53
  • Just a suggestion to add to your list of solutions/ideas: a `TextDrawable`. There are several implementations readily floating around. The [simplest one](https://android.googlesource.com/platform/packages/apps/Camera/+/master/src/com/android/camera/drawable/TextDrawable.java) comes straight from Google. [These](https://github.com/amulyakhare/TextDrawable/blob/master/library/src/main/java/com/amulyakhare/textdrawable/TextDrawable.java) [two](https://github.com/devunwired/textdrawable/blob/master/sample/src/main/java/com/example/textdrawable/drawable/TextDrawable.java) offer some more features. – MH. Nov 03 '15 at 09:54