package org.sunday.uiext;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
/**
* @author sunday
* 2013-12-5
* 邮箱:zhengchao1937@163.com
* QQ:804935743
*/
public class ViewAllShowLinearLayout extends LinearLayout {
private View mView; // 顶部的View
private ViewSwitchListener viewSwitchListener; // 对外钩子接口
private ScrollView mScrollView;
private boolean isFlag = true; //辅助判断变量
public void initData(View view, ScrollView scrollview,
ViewSwitchListener viewSwitchListener) {
this.mView = view;
this.mScrollView = scrollview;
this.viewSwitchListener = viewSwitchListener;
}
public ViewAllShowLinearLayout(Context context) {
super(context);
init();
}
public ViewAllShowLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
setOrientation(LinearLayout.VERTICAL);
}
@Override
public void computeScroll() {
if (mView != null && mScrollView != null && viewSwitchListener != null) {
int y = mScrollView.getScrollY();
if (isFlag) {
int top = mView.getTop();
if (y >= top) {
viewSwitchListener.onViewShow();
isFlag = false;
}
}
if (!isFlag) {
int bottom = mView.getBottom();
if (y <= bottom - mView.getHeight()) {
viewSwitchListener.onViewGone();
isFlag = true;
}
}
}
}
public interface ViewSwitchListener {
public void onViewShow();
public void onViewGone();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有