How to make a buttons bar slide in from bottom upon clicking checkbox in ListView?

前端 未结 2 896
天涯浪人
天涯浪人 2021-01-14 13:30

I have a listview with custom listadapter, which populates the listview with a checkbox and some textviews. When the user selects a checkbox, I need a button bar to slide in

2条回答
  •  心在旅途
    2021-01-14 14:01

    Below is the runtime code implementation, modify accordingly if you need it for other purposes.

    RelativeLayout rl = new RelativeLayout(this);
    ImageButton btnBar = new ImageButton(this);
    
    RelativeLayout.LayoutParams btnParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 80);
    
    btnParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    
    btnBar.setLayoutParams(btnParams);
    btnBar.setBackgroundColor(Color.RED); // test with red background
    
    TranslateAnimation a = new TranslateAnimation(
                               Animation.RELATIVE_TO_PARENT, 0,
                               Animation.RELATIVE_TO_PARENT, 0,
                               Animation.RELATIVE_TO_PARENT, (float)100, 
                               Animation.RELATIVE_TO_PARENT, (float)0);
    
    a.setDuration(1000);
    btnBar.startAnimation(a); // add animation while start
    
    rl.addView(btnBar);
    setContentView(rl);
    

提交回复
热议问题