Code example for View

Methods: getHeight, getLayoutParams, setLayoutParams

0
        public void onDragFloatView(View floatView, Point floatPoint, Point touchPoint) {
            final int first = mDslv.getFirstVisiblePosition();
            final int lvDivHeight = mDslv.getDividerHeight();
 
            if (origHeight == -1) {
                origHeight = floatView.getHeight();
            } 
 
            View div = mDslv.getChildAt(mDivPos - first);
 
            if (touchPoint.x > mDslv.getWidth() / 2) {
                float scale = touchPoint.x - mDslv.getWidth() / 2;
                scale /= (float) (mDslv.getWidth() / 5);
                ViewGroup.LayoutParams lp = floatView.getLayoutParams();
                lp.height = Math.max(origHeight, (int) (scale * origHeight));
                Log.d("mobeta", "setting height "+lp.height);
                floatView.setLayoutParams(lp);
            } 
 
            if (div != null) {
                if (mPos > mDivPos) {
                    // don't allow floating View to go above 
                    // section divider 
                    final int limit = div.getBottom() + lvDivHeight;
                    if (floatPoint.y < limit) {
                        floatPoint.y = limit;
                    } 
                } else { 
                    // don't allow floating View to go below 
                    // section divider 
                    final int limit = div.getTop() - lvDivHeight - floatView.getHeight();
                    if (floatPoint.y > limit) {
                        floatPoint.y = limit;
                    } 
                } 
            }