我正在尝试为水平列表项设置动画,关闭 alpha 动画作品,并且 layoutparam 值也会随着时间的推移而减少,但由于某种原因,这不会改变列表项的实际高度。
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final int initialHeight = view.getMeasuredHeight();
if(interpolatedTime == 1){
imageAdapter.remove(view, position);
}else{
view.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
view.setAlpha(1 - interpolatedTime);
System.out.println(" v height = " + view.getHeight());
System.out.println(" v layoutparams = " + view.getLayoutParams().height);
view.forceLayout();
view.invalidate();
view.requestLayout();
}
}
这是在 imadeAdapter 的 getView 方法中,binBtn 是您触摸以删除列表项的按钮
binBtn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_UP)
{
View vp = (View) v.getParent();
SqueezeAnimation ani = new SqueezeAnimation(this,vp,position);
ani.setDuration(1000);
v.startAnimation(ani);
在 Tanis 回答后更改此代码,但问题仍然相同, getHeight() 打印 674 和 getLayoutParams().height 打印 100
else{
RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(100, 100);
view.setLayoutParams(lps);
view.requestLayout();
System.out.println(" v height = " + view.getHeight());
System.out.println(" v layoutparams = " + view.getLayoutParams().height);
作为旁注,这是在 imageadapter 的 getView 方法中,它改变了该视图的高度,我尝试将 backgroundfillIV 传递给动画但仍然不起作用
View backgroundfillIV = gridView.findViewById(R.id.backroundfillbar);
double mult = products.get(position).value/ products.get(0).value;
backgroundfillIV.getLayoutParams().height = (int) ( (((bottleheight+20)*0.95)/mult));