2

In my application I want to create a dropDown that shows data, but the dropDown looks like a dropDown as shown in web not like a spinner.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
Sats
  • 875
  • 6
  • 12

2 Answers2

4

I have created a dropdown demo project on github to help out with this I'm my mind missing view/widget.

Its based on a text view (title) used to display the currently selected alternative, and a linear layout containing the alternative. When the title is clicked i animate in the linear layout with the alternatives, and once a alt is selected the linear layout is animated out.

The project can be found here:

https://github.com/erbsman/DropDownDemo

hope this helps :)

Carl-Emil Kjellstrand
  • 1,233
  • 1
  • 10
  • 17
0

You can create an animation class like this

public class DropDownAnimation extends Animation {
    public int height, width;

    @Override
    public void initialize(int width, int height, int parentWidth,
            int parentHeight) {
        // TODO Auto-generated method stub
        super.initialize(width, height, parentWidth, parentHeight);
        this.width = width;
        this.height = height;
        setDuration(500);
        setFillAfter(true);
        setInterpolator(new LinearInterpolator());
    }

    Camera camera = new Camera();

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        // TODO Auto-generated method stub
        super.applyTransformation(interpolatedTime, t);

        Matrix matrix = t.getMatrix();
        camera.save();

        camera.getMatrix(matrix);
        matrix.setTranslate(0, (height * interpolatedTime));

        matrix.preTranslate(0, -height);
        camera.restore();

        this.setAnimationListener(this);
    }

and use it like this :

    LinearLayout ll = (LinearLayout) findViewById(R.id.parentLayout);
    ll.startAnimation(new DropDownAnimation());
Vinay W
  • 9,912
  • 8
  • 41
  • 47