android - 使用 android:layout_margin 设置时 layout_marginBottom 无效
问题描述
在继续发布这个问题之前,我在 SO 上尝试了多个答案。这些都没有帮助。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<allosh.xvideo.player.views.PlayerVideoView
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"/>
</RelativeLayout>
</RelativeLayout>
LinearLayoutandroid:layout_marginBottom="100dp"
不做任何事情,但android:layout_margin="5dp"
具有可见的效果。
我不仅在寻找解决方案,而且还在寻找适当的解释。这将是有益的和感激的。
解决方案
你应该:
- 设置 marginLeft、marginRight 和 marginTop 而不是 margin
- 从 PlayerVideoView 中删除 layout_alignParentBottom
- 为您的 PlayerVideoView 设置 alignBottom
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<allosh.xvideo.player.views.PlayerVideoView
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/linear1"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"/>
</RelativeLayout>
</RelativeLayout>
推荐阅读
- python - Discord.py 排名命令
- javascript - 为什么这会在 Web 控制台编译器中显示以及如何修复它并找到值
- excel - Worksheet_Change Target.Address 在特定工作表上
- java - Project Euler #14 输出的输出不正确
- javascript - 如何根据数据属性对父 div 中的子 div 进行排序?
- javascript - d3.js 分子图仅适用于对象的最后一个元素
- material-ui - Material UI React - 循环中的模态数据仅显示最后一次迭代数据
- javascript - 如何在 Materials-UI 中更改选项卡组件的大小?
- logstash - 无法将新更新的事件从 filebeat 发送到 logstash
- python - 查找一列的最小和最大行并减去另一列的值