János János - 3 months ago 12
Android Question

android:layout_marginLeft refer to the parent view or views around?

I have set

android:layout_marginLeft
attribute, and I do not understand whether it will keep distance / margin to the parent or to the next view beside?

Doc only says :
Specifies extra space on the left side of this view. This space is outside this view's bounds. Margin values should be positive.
.

Answer

It depends on the parent layout.

If it's LinearLayout, RelativeLayout, TableRow then android:layout_marginLeft attribute will specifies extra space on the left side of one above child of the same parent view hierarchy (views around).

If it's FrameLayout then android:layout_marginLeft attribute will specifies extra space on the left side to its parent. It doesn't affect by other child of same parent.

Comments