Search code examples
androidlayoutandroid-custom-viewdropdownbox

Create a Dropdown to show more Views in Android


I am trying to code a layout, but I do not know well how to approach it.

Initially I have the following:

enter image description here

When the user click in this View, I need to show:

enter image description here

I thought I will need a Spinner, but the content that is shown when the user click is not a list but a set of Views (In this case, it will be a LinearLayout with a Spinner and a EditText).

I am a little lost, what would be the best approach to achieve this?

Do I need to implement a CustomView?

Sorry if it is a dummy question, but I can figure out how to code this Layout.


Solution

  • I think the best approach would be to make a LinearLayout in wich you can place you Spinner and your Search EditText and set this LinearLayout ViewGroup setVisible(View.INVISIBLE).

    Then when you click on the "registra alimento" View set the LinearLayout below to setVisible(View.VISIBLE)

    To fade it in:

    Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
    viewToAnimate.startAnimation(in);
    viewToAnimate.setVisibility(View.VISIBLE);