I have FrameLayout and for most fragments the parrent padding is good. But I have especial fragment which must not contain the padding.
<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!
As a 1st thought, adding a class or ID to the child menu would do your job. you can use CSS :not when it comes to child ul or li . Also a child menu can be usually selected like ul li ul li when a parent can be selected like ul li .
You can try adding a fixed height to the parent which might work or put enough content in the child to stretch it; that will work. Show activity on this post. You have margin-bottom set on both elements. With the child having a bottom margin, it will always be smaller by that amount.
You cannot "disable" or "turnoff" inhertiance in CSS. The best you could do is "negate" it such as if parent has color: red; than child will also be red. So on child you can set color: black; Only some, not all, CSS properties are inherited.
Curious, just using layout_margin
does not seem to work. However,
<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).
Do not forget: android:clipToPadding="false"
in the parent layout.
Seems like things would be easier if you would just remove the android:padding="10dp"
from your FrameLayout and in your "normal" fragments you add the 10dp padding, while in your "special" fragment you don't add any padding. Negative margins can be done, but in my opinion should only be used if there is no other way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With