Jevon
Jevon

Reputation: 313

Is padding only included in a view size if its set to wrap content?

In this example, there will be no text shown as it is covered by padding.

<TextView
     android:padding="250px"
     android:layout_width="500px"
     android:layout_height="500px"
     android:background="@color/yellow"
     android:text="some text"
     android:textColor="@color/red"/>

however, in this example the padding will be added onto the sizes thus there will be a larger textview and visible text.

<TextView
      android:padding="250px"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@color/yellow"
      android:text="some text"
      android:textColor="@color/red"/>

Is there a way in pure xml to set an arbitrary width and/or height and have the view size include the padding just like with html?

Upvotes: 1

Views: 1173

Answers (1)

sebschaef
sebschaef

Reputation: 244

Just decide on a certain size and add the paddings onto it.

<----------------- 1000px ---------------->
<-- 250px --><---- 500px ----><-- 250px -->

Otherwise you can still use a margin.

Upvotes: 2

Related Questions