Is there a way to fill parent minus a fixed number in Android RelativeLayout?

Anthony Frizalone picture Anthony Frizalone · Jun 23, 2012 · Viewed 19.4k times · Source

I have an ImageButton that I want to fill its parent RelativeLayout container for its width but minus a few dp so it has some left and right padding. I tried fill_parent-10dp but that causes an error and doesn't render.

Answer

you786 picture you786 · Jun 23, 2012

Put a android:layout_margin="10dp" on the ImageButton, along with the

android:layout_width="fill_parent"
android:layout_height="fill_parent"