vb listview第一列可以固定不动吗 就像Excel中固定窗格一样?
2016-05-12
展开全部
vb listview第一列可以固定不动
还是自己解决的,需要重新布局当前的layout,红色标记部分是关键,拿来与大家分享一下!
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX,
boolean clampedY) {
//Log.e(TAG, "onOverScrolled(),scrollX=" +scrollX + ",scrollY="+scrollY+
//",clampedX="+clampedX+",clampedY:"+clampedY+",mAddHeader="+mAddHeader);
//判断向下滚动,重新布局
if(scrollY < 0 ){
mAddHeader = true;
if(mSearchView != null){
mSearchView.layout(0, scrollY, mSearchViewWidth, mSearchViewHeight + scrollY);
this.setHeaderDividersEnabled(false);
}
//向上滚动时,重新布局
}else if(scrollY >= 0 && mAddHeader ){
mAddHeader = false;
requestLayout();
}
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
}
@Override
public void addHeaderView(View v) {
super.addHeaderView(v);
mSearchView = (ViewGroup) v;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mSearchView != null) {
mSearchViewWidth = mSearchView.getMeasuredWidth();
mSearchViewHeight = mSearchView.getMeasuredHeight();
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mSearchView != null) {
mSearchView.layout(0, 0, mSearchViewWidth, mSearchViewHeight);
}
}
还是自己解决的,需要重新布局当前的layout,红色标记部分是关键,拿来与大家分享一下!
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX,
boolean clampedY) {
//Log.e(TAG, "onOverScrolled(),scrollX=" +scrollX + ",scrollY="+scrollY+
//",clampedX="+clampedX+",clampedY:"+clampedY+",mAddHeader="+mAddHeader);
//判断向下滚动,重新布局
if(scrollY < 0 ){
mAddHeader = true;
if(mSearchView != null){
mSearchView.layout(0, scrollY, mSearchViewWidth, mSearchViewHeight + scrollY);
this.setHeaderDividersEnabled(false);
}
//向上滚动时,重新布局
}else if(scrollY >= 0 && mAddHeader ){
mAddHeader = false;
requestLayout();
}
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
}
@Override
public void addHeaderView(View v) {
super.addHeaderView(v);
mSearchView = (ViewGroup) v;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mSearchView != null) {
mSearchViewWidth = mSearchView.getMeasuredWidth();
mSearchViewHeight = mSearchView.getMeasuredHeight();
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mSearchView != null) {
mSearchView.layout(0, 0, mSearchViewWidth, mSearchViewHeight);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询