简体   繁体   English

片段:覆盖活动边距

[英]Fragment: overwrite activities margin

I have an Activity container for several different fragments. 我有几个不同片段的Activity容器。 All fragments should have the same margin except one. 除一个片段外,所有片段应具有相同的边距。 This should has no margin. 这应该没有余量。 But how can I do that? 但是我该怎么办呢?

This is my activity_container.xml: 这是我的activity_container.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragmentContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="15dp" />

All fragments within this container have a margin of 15dp. 此容器中的所有片段的边距为15dp。 But there is one fragment, that should have 0 dp. 但是有一个片段,应该有0 dp。 The fragment have to be in the container. 片段必须在容器中。 So creating a container only for this fragment is no option. 因此,仅为此片段创建容器是没有选择的。 Do somebody has an idea to solve that problem? 有人有解决这个问题的想法吗?

The fragments cannot be displayed outside of their container, just as with any other view. 片段无法像其他任何视图一样在其容器外显示。

Your only option is to remove the margin from your relative layout and add it back as padding onto the individual fragment layouts 唯一的选择是从相对布局中删除边距,并将其作为填充重新添加到各个片段布局中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM