This is one of the most common questions around Android layout, and one that’s not at all intuitive or well documented.

Let’s take the most simple use case: you have a thumbnail that’s 75dp on the right, and you want a TextView to take up the rest of the space. Of course, you could satisfy this simple requirement with `drawableLeft` on the TextView, but let’s assume that either one of those are compond elements (e.g., instead of a TextView, maybe there’s a header, a summary and a link – or instead of a thumbnail ImageView, it’s a compound widget like a Switch).

The answer is to use a LinearLayout, and layout_weight only on the elements you want to expand, and give that element a corresponding dimension of 0dp.




Notice the first ImageView will be as big as it wants to be; the ImageView at the end (on the right) will be exactly 20dp, and the TextView will take up whatever space is left.