【发布时间】:2021-07-18 11:29:58
【问题描述】:
我有一个包含布局的底页。并且该布局具有相对布局。哪个有默认边距。即使我将边距设置为 0dp,它也不起作用。
bottom_sheet_back.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/blue_back"/>
</RelativeLayout>
里面的代码 activity_main.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:elevation="10dp"
android:padding="0dp">
<com.google.android.material.bottomappbar.BottomAppBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<include layout="@layout/bottom_sheet_back"/>
</com.google.android.material.bottomappbar.BottomAppBar>
这给了我这样的结果。
其中 bottom_sheet_back.xml 具有全宽。
正如您在第一张图片中看到的那样,我想删除该边距。
已尝试解决方案
以上解决方案在我的场景中没有太大帮助。我尝试了另一种解决方案,它是编辑dimens.xml,但是我似乎无法在任何地方找到它。我使用默认具有约束布局的android studio 4.1.3。因此,dimens.xml 不是由项目生成的。但是,如果它不是由项目生成的,那么RelativeLayout 是如何获得利润的呢?
我们将不胜感激。
【问题讨论】:
标签: android android-relativelayout default-value