如何在Android中通过Java在一个布局中覆盖填充

如何在Android中通过Java在一个布局中覆盖填充,java,android,Java,Android,我正在创建一个带有导航抽屉的android应用程序,我不想放弃默认的dimens vaules,它是: <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> 问候 ////编辑 以下是我的片段的xml: <RelativeLayout xmlns:android="http://sc

我正在创建一个带有导航抽屉的android应用程序,我不想放弃默认的dimens vaules,它是:

<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

问候

////编辑 以下是我的片段的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.test.SchoolFragment">

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_height="match_parent"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            tools:context="com.example.mapwithmarker.MapsMarkerActivity" />

</RelativeLayout>


在修改片段根视图的填充时,此处的填充/边距设置为活动。在这种情况下,“活动”中设置的填充/边距将保持不变,即
16dp
。尝试删除活动根视图的填充/边距。

view.setPadding(-16,-16,-16650);不幸的是,这不适用于负值。我应该如何正确地执行?在活动的布局xml文件中,删除与填充/边距相关的属性。i、 e
android:paddingBottom
android:paddingTop
android:layout\u marginBottom
android:layout\u marginTop
等。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.test.SchoolFragment">

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_height="match_parent"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            tools:context="com.example.mapwithmarker.MapsMarkerActivity" />

</RelativeLayout>