zoukankan      html  css  js  c++  java
  • 无滚动条GridView少量图片展示

    import android.content.Context;
    import android.util.AttributeSet;
    import android.util.Log;
    import android.view.MotionEvent;
    import android.widget.GridView;
    
    public class NoScrollGridView extends GridView {
    
        private static final String TAG = "NoScrollGridView";
        private static final int BLANK_POSITION = -1;
        private OnTouchBlankPositionListener mTouchBlankPosListener;
    
        public NoScrollGridView(Context context) {
            super(context);
        }
    
        public NoScrollGridView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, expandSpec);
        }
    
        public interface OnTouchBlankPositionListener {
            boolean onTouchBlankPosition();
        }
    
        public void setOnTouchBlankPositionListener(OnTouchBlankPositionListener listener) {
            mTouchBlankPosListener = listener;
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
    
            if (mTouchBlankPosListener != null) {
                if (!isEnabled()) {
                    // A disabled view that is clickable still consumes the touch
                    // events, it just doesn't respond to them.
                    return isClickable() || isLongClickable();
                }
                if (event.getActionMasked() == MotionEvent.ACTION_UP) {
                    final int motionPosition = pointToPosition((int) event.getX(), (int) event.getY());
                    if (motionPosition == BLANK_POSITION) {
                        return mTouchBlankPosListener.onTouchBlankPosition();
                    }
                }
            }
            return super.onTouchEvent(event);
        }
    }
  • 相关阅读:
    完整的UED流程
    curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
    部署方案模板
    商城项目合作
    架构师分类
    k8s视图
    虚拟化通信技术
    AxureRP8 实现时间功能
    在AxureRP8中实现广告文字滚动效果
    获取当前网络中的电脑数目及MAC-通过MAC查找IP-通过IP查询机器名
  • 原文地址:https://www.cnblogs.com/magics/p/4056128.html
Copyright © 2011-2022 走看看