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
-
possible duplicate of stackoverflow.com/questions/3451889/android-popup-menuGanesh K– Ganesh K2012-07-12 09:43:51 +00:00Commented Jul 12, 2012 at 9:43
-
If you are working with API Level 11 or above developer.android.com/reference/android/widget/PopupMenu.htmlGanesh K– Ganesh K2012-07-12 09:45:44 +00:00Commented Jul 12, 2012 at 9:45
Add a comment
|
2 Answers
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 :)
1 Comment
Carl-Emil Kjellstrand
youtube.com/watch?v=JX9RmLAoOUY for a video of how it looks, to help you decide if this is what you want :)
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());