android - 按钮在约束布局中没有完全粘在屏幕底部
问题描述
我将一个按钮约束到屏幕底部,但不幸的是屏幕底部边框和按钮底部边框之间有一个小间隙:
我的 XML:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.tabs.TabLayout
android:id="@+id/navigationTabs"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent"
app:tabMinWidth="100dp"
app:tabRippleColor="@null"
/>
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="BUTTON"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"/>
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/navigationTabs" />
</androidx.constraintlayout.widget.ConstraintLayout>
造成这种差距的原因是什么?我怎样才能摆脱它?
解决方案
它是默认背景按钮周围的阴影。指定你自己的背景,差距就会消失。例如:
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#A4ABA4"
android:text="BUTTON"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"/>
推荐阅读
- javascript - 在 QuillJS 中将自定义类添加到块引用
- c++ - Esp-32 从 'const char*' 到 'int' 的无效转换 [-fpermissive]
- r - 使用 Shiny 更新数据帧值并在 Shiny 会话结束后在本地环境中访问它
- c - C中gcvt()和_gcvt()的区别
- react-native - 有人可以帮助我,以便当我单击按钮时,计时器会重置吗?谢谢
- javascript - Angular 9:如何防止iOS键盘在将焦点从输入更改为表单内的另一个时消失
- c++ - 如果包含,有条件地将功能从一个标头集成到另一个标头中(这甚至有必要吗?)
- discord.py - 我如何检查某人是否具有特定角色 discord py
- javascript - 如何找到数组中连续零序列的所有第一个索引?
- splunk - splunk 报告中的空白 CSV