Code example for RelativeLayout

Methods: setGravity, addView, getLayoutParams, getVisibility, setLayoutParams, setVisibility

0
				} 
			} else { 
				AbsListView.LayoutParams params = new AbsListView.LayoutParams(
						ViewGroup.LayoutParams.MATCH_PARENT,
						ViewGroup.LayoutParams.WRAP_CONTENT);
				v = new RelativeLayout(getContext());
				v.setLayoutParams(params);
				child = mAdapter.getView(position, null, v);
				v.addView(child);
				v.setTag(child.findViewById(R.id.drag));
			} 
			ViewGroup.LayoutParams lp = v.getLayoutParams();
			final int numHeaders = getHeaderViewsCount();
			final int srcAdapter = mSrcDragPos - numHeaders;
			final int expAdapter = mExpDragPos - numHeaders;
			boolean itemIsNormal = position != srcAdapter
					&& position != expAdapter;
			boolean listHasExpPos = mDragState == SRC_ABOVE
					|| mDragState == SRC_BELOW;
			boolean itemNeedsWC = itemIsNormal || !listHasExpPos;
			int oldHeight = lp.height;
			if (itemNeedsWC && lp.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
				lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
			} else if (listHasExpPos) {
				if (position == srcAdapter && lp.height != mItemHeightCollapsed) {
					lp.height = mItemHeightCollapsed;
				} else if (position == expAdapter) {
					int spec = MeasureSpec.makeMeasureSpec(0,
							MeasureSpec.UNSPECIFIED);
					child.measure(spec, spec);
					mExpandedChildHeight = child.getMeasuredHeight();
					int height = mExpandedChildHeight + mFloatViewHeight;
					if (lp.height != height)
						lp.height = height;
					if (mDragState == SRC_ABOVE) {
						v.setGravity(Gravity.TOP);
					} else 
						v.setGravity(Gravity.BOTTOM);
				} 
			} 
			if (lp.height != oldHeight)
				v.setLayoutParams(lp);
			int oldVis = v.getVisibility();
			int vis = oldVis;
			if (position == srcAdapter && mDragState != NO_DRAG
					&& vis == View.VISIBLE) {
				vis = View.INVISIBLE;
			} else if (vis == View.INVISIBLE)
				vis = View.VISIBLE;
			if (vis != oldVis)
				v.setVisibility(vis);
			return v;
		} 
	} 
 
	private int getItemHeight(int position) {