How to reject a parent pad in a child

I have a FrameLayout , and for most fragments, debugging works fine. But I have a special fragment that should not contain indents.

<FrameLayout android:id="@+id/frame_content" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" /> <!-- My especial fragment --> <LiearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:padding="-10dp" /> 

Any suggestions!

+5
source share
2 answers

Curiously, using layout_margin doesn't work. Nonetheless,

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" android:clipToPadding="false"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="-10dp" android:layout_marginStart="-10dp" android:layout_marginEnd="-10dp" android:layout_marginBottom="-10dp" /> </FrameLayout> 

seems to work (IntelliJ android preview).

Remember: android:clipToPadding="false" in the parent layout.

+13
source

It seems that it would be easier if you simply removed android:padding="10dp" from your FrameLayout, and in your "normal" fragments you added the addition of 10dp, while in your "special" fragment you do not add any additions . Negative fields can be made, but, in my opinion, they should be used only if there is no other way to do this.

0
source

All Articles