Change UITableView height dynamically

There isn’t a system feature to change the height of the table based upon the contents of the tableview. Having said that, it is possible to programmatically change the height of the tableview based upon the contents, specifically based upon the contentSize of the tableview (which is easier than manually calculating the height yourself). A … Read more

When Can I First Measure a View?

I didn’t know about ViewTreeObserver.addOnPreDrawListener(), and I tried it in a test project. With your code it would look like this: public void onCreate() { setContentView(R.layout.main); final TextView tv = (TextView)findViewById(R.id.image_test); final LayerDrawable ld = (LayerDrawable)tv.getBackground(); final ViewTreeObserver obs = tv.getViewTreeObserver(); obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw () { Log.d(TAG, “onPreDraw tv height is … Read more

Setting width/height as percentage minus pixels

You can use calc: height: calc(100% – 18px); Note that some old browsers don’t support the CSS3 calc() function, so implementing the vendor-specific versions of the function may be required: /* Firefox */ height: -moz-calc(100% – 18px); /* WebKit */ height: -webkit-calc(100% – 18px); /* Opera */ height: -o-calc(100% – 18px); /* Standard */ height: … Read more

How to make a div 100% height of the browser window

There are a couple of CSS 3 measurement units called: Viewport-Percentage (or Viewport-Relative) Lengths What are Viewport-Percentage Lengths? From the linked W3 Candidate Recommendation above: The viewport-percentage lengths are relative to the size of the initial containing block. When the height or width of the initial containing block is changed, they are scaled accordingly. These … Read more

How to get the width and height of an android.widget.ImageView?

My answer on this question might help you: int finalHeight, finalWidth; final ImageView iv = (ImageView)findViewById(R.id.scaled_image); final TextView tv = (TextView)findViewById(R.id.size_label); ViewTreeObserver vto = iv.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { iv.getViewTreeObserver().removeOnPreDrawListener(this); finalHeight = iv.getMeasuredHeight(); finalWidth = iv.getMeasuredWidth(); tv.setText(“Height: ” + finalHeight + ” Width: ” + finalWidth); return true; } }); You can … Read more

Make iframe automatically adjust height according to the contents without using scrollbar? [duplicate]

Add this to your <head> section: <script> function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + ‘px’; } </script> And change your iframe to this: <iframe src=”https://stackoverflow.com/questions/9975810/…” frameborder=”0″ scrolling=”no” onload=”resizeIframe(this)” /> As found on sitepoint discussion.