Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

December 22 2011

schlingel

Android: Drawing slider onMeasure content size sensitive

	    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
	        int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
	        int widthSpecSize =  MeasureSpec.getSize(widthMeasureSpec);

	        int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
	        int heightSpecSize =  MeasureSpec.getSize(heightMeasureSpec);

	        if (widthSpecMode == MeasureSpec.UNSPECIFIED || heightSpecMode == MeasureSpec.UNSPECIFIED) {
	            throw new RuntimeException("SlidingDrawer cannot have UNSPECIFIED dimensions");
	        }

	        final View handle = getHandle();
	        final View content = getContent();
	        measureChild(handle, widthMeasureSpec, heightMeasureSpec);

	        if (vertical) {
	            int height = heightSpecSize - handle.getMeasuredHeight() - topOffset;
	            content.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, heightSpecMode));
	            heightSpecSize = handle.getMeasuredHeight() + topOffset + content.getMeasuredHeight();
	            widthSpecSize = content.getMeasuredWidth();
	            if (handle.getMeasuredWidth() > widthSpecSize) widthSpecSize = handle.getMeasuredWidth();
	        }
	        else {
	            int width = widthSpecSize - handle.getMeasuredWidth() - topOffset;
	            getContent().measure(MeasureSpec.makeMeasureSpec(width, widthSpecMode), heightMeasureSpec);
	            widthSpecSize = handle.getMeasuredWidth() + topOffset + content.getMeasuredWidth();
	            heightSpecSize = content.getMeasuredHeight();
	            if (handle.getMeasuredHeight() > heightSpecSize) heightSpecSize = handle.getMeasuredHeight();
	        }

	        setMeasuredDimension(widthSpecSize, heightSpecSize);
	    }	
Reposted byurfin urfin

September 16 2010

schlingel
Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.

Don't be the product, buy the product!

Schweinderl