我在列表视图上方有一个布局,位于主布局的底部。 当我滚动列表时,我想让顶部布局更小。我正在尝试使用列表视图滚动侦听器并更改布局参数的宽度和高度。 问题是这个程序根本不顺利,占用了大量资源。 如何在不使用布局参数的情况下重新调整顶视图的大小(吃掉很多资源)?
我为listview设置的滚动侦听器:
public class EndLessScrolling实现AbsListView.OnScrollListener {
private int amountViewInitDimension = 0;
public EndLessScrolling() {}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//amountView on scroll resize effect
if (firstVisibleItem < 5) {
View amountView = getActivity().findViewById(R.id.select_receiver_amount_parent);
if (amountView != null) {
ViewGroup.LayoutParams params = amountView.getLayoutParams();
if (amountViewInitDimension == 0) {
amountViewInitDimension = params.width;
}
params.width = amountViewInitDimension - firstVisibleItem * amountViewInitDimension / 10;
params.height = amountViewInitDimension - firstVisibleItem * amountViewInitDimension / 10;
receiverAmount.setTextSize(TypedValue.COMPLEX_UNIT_SP, amountTextSize - firstVisibleItem * zoomStep);
dollarSign.setTextSize(TypedValue.COMPLEX_UNIT_SP, dollarSignTextSize - firstVisibleItem * zoomStep / 2f);
amountView.setLayoutParams(params);
}
}
}
}