farindk
farindk

Reputation: 260

Android layout overlay

On Android devices, one can switch on a layout overlay in the developer options. That should be simple, but I don't understand what the red border actually shows.

This is a screen-shot of my layout:

Android layout overlay

and this is the corresponding XML:

<Button
  android:id="@+id/keypad_4"
  android:text="4"
  android:layout_below ="@id/keypad_7"
  android:layout_alignLeft="@id/valueEntry"
  android:layout_width ="70dp"
  android:layout_height="60dp"
  android:layout_margin="0dp"
  android:padding="0dp" />
<Button
  android:id="@+id/keypad_5"
  android:text="5"
  android:layout_below ="@id/keypad_8"
  android:layout_toRightOf = "@id/keypad_4"
  android:layout_width ="70dp"
  android:layout_height="60dp"
  android:layout_margin="0dp"
  android:padding="0dp" />

To my understanding, the blue corners indicate the View's width and height, while the red border should show the actual content after padding has been applied.

Now, why is the red border still inset even though padding is zero? Does the Button class ignore the padding and apply its own fixed value?

Upvotes: 0

Views: 165

Answers (1)

farindk
farindk

Reputation: 260

Answering my own question: apparently my understanding of the layout overlay is correct, but a Button takes its padding from the background drawable. In this case (Holo theme), this is a 9-patch with built-in padding. The value in the XML is ignored.

Upvotes: 1

Related Questions