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.

2

2 Answers 2

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 :)

Sign up to request clarification or add additional context in comments.

1 Comment

youtube.com/watch?v=JX9RmLAoOUY for a video of how it looks, to help you decide if this is what you want :)
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());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.