java - 底部工具栏边框与工具栏android studio的高度不匹配
问题描述
我试图让我的按钮适合底部工具栏的边框。现在我的底部工具栏看起来像这样。
以及底部工具栏的以下 xml 文件。
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="@drawable/white_grey_border_bottom"
android:gravity="bottom"
android:minHeight="?attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<Button
android:id="@+id/homeIcon"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:background="@drawable/home" />
<Button
android:id="@+id/calendarIcon"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="32dp"
android:background="@drawable/calendar_alt" />
<Button
android:id="@+id/heartIcon"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="124dp"
android:background="@drawable/oval_84" />
<Button
android:id="@+id/userIcon"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="32dp"
android:background="@drawable/user" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<Button
android:id="@+id/floatingActionButton"
android:layout_width="58dp"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="24dp"
android:background="@drawable/group" />
浮动操作按钮旨在突出工具栏,但我的其余图标应在边框内。我使用这个可绘制资源来设置我的边框。
white_grey_border xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="1dp">
<item
android:bottom="-1dp"
android:right="-1dp"
android:left="-1dp"
android:top="11dp">
<shape
android:shape="rectangle">
<stroke android:width="0.5dp"
android:color="@color/colorGrey"/>
<solid android:color="@color/colorWhite"/>
</shape>
</item>
以前我的按钮在工具栏和线性布局高度内,但是在添加边框后它不适合工具栏的高度,因此为什么灰色图标突出。先感谢您 :)
解决方案
哎呀,我想我已经解决了,我可以将白色灰色边框 xml 的顶部从 11dp 更改为 1 dp 或 sth 。感谢您的回答。
推荐阅读
- login - 随时随地自动登录
- python-3.x - 如何提取服务器用 Python 请求发送的 cookie
- python - Python 3.6 在运行时导入
- laravel - Laravel 自定义变形关系与自定义表结构
- c# - 调用同步代码的选项
- angular - 如何使用 div 作为 ViewChild 测试角度组件
- r - 将字符向量的每个元素与第二个向量 r 的所有元素连接起来
- javafx - 丢弃的文件只移动一位然后异常
- knockout.js - Knockout Js:可观察数组的 SORT 函数如何工作
- java - 如何将参数传递给在 Tomcat 上运行的 Web 应用程序