R
R
Rizvan Gereykhanov2014-11-26 22:30:49
Android
Rizvan Gereykhanov, 2014-11-26 22:30:49

How to dynamically resize a ListViewItem with animation added?

There is a ListView with a custom adapter and hence a listViewItem with interface elements (button, textView, textEdit, IimageView). When you click on a certain Item, the size of the Item (a) itself changes through setMinimumHeight (in height), but how to make a size change with the addition of animation? For example with a smooth increase in size.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Noxa, 2014-11-26
@Gereykhanov

Use the official guide.
developer.android.com/guide/topics/graphics/prop-a...
You were on the right track. You can get the click event on an element in two places:
1) In the adapter, when the View is created
2) In the activity, by calling getListView().setOnItemClickListener()

getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view,"minimumHeight",300);
                objectAnimator.setDuration(2000);
                objectAnimator.start();
            }
        });

R
Rizvan Gereykhanov, 2014-11-26
@Gereykhanov

yes, but the moment of applying these animations directly to the Item(s) is important to me, for example, in order to call the button animation, you need:

final Animation animRotate = AnimationUtils.loadAnimation(this, R.anim.anim_rotate);
  
       Button button = (Button) findViewById(R.id.button);

       button.setOnClickListener(new Button.OnClickListener() {
                   @Override
                    public void onClick(View view) {
                    view.startAnimation(animRotate);
                    }});

but what about listViewItem and how to apply it to it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question