Hello. You must implement a view element that expands when clicked. The example is implemented in the clock application in Android (see screenshots). Tell me which way to google, or maybe there are standard implementations. ExpandableTextView looked, but, it seems to me, this is not exactly what I need.

enter image description here

enter image description here

  • Any View has a visibility parameter (in XML - android:visibility or in the code setVisibility() method). For elements that should not be displayed in the "hidden" state, assign it to View.GONE . When you need to "open" - install View.VISIBLE for them and that's it. - pavlofff pm
  • @pavlofff but there is not only visibility, the rest of the view goes down as well - user214046
  • Here is a ListView ( RecyclerView ), each alarm clock has an item in it. When you change the visibility of items in the item, everything will shift as it should after updating the list adapter. - pavlofff
  • @pavloff did not know, I will go. If so, thank you so much! Long suffered) - user214046
  • @pavlofff yes, it works. But I'm not doing it in RecyclerView, but simply in a fragment. And such a question, how can you achieve a smooth opening of an invisible field? Is there a standard behavior for this, or should I write it myself? I use CoordinatorLayout - user214046

1 answer 1

At the heart of this screen - the ListView or RecyclerView / Adapter of this list should display two types of items - expanded and compressed. In the data for the adapter, there should be a field defining the state of each item (it is revealed or hidden).
The getView() method of the adapter reads this field and sets the appropriate visibility for display by the setVisiblity() method for the items attached to the item.

When you click on the disclosure \ hide button, the corresponding state is recorded in the data and the adapter is updated to redraw the new view.

RecyclerView allows you to use animations of this process through the notifyItemChanged() method