首页 > 解决方案 > 底部工具栏边框与工具栏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>

以前我的按钮在工具栏和线性布局高度内,但是在添加边框后它不适合工具栏的高度,因此为什么灰色图标突出。先感谢您 :)

标签: javaandroid

解决方案


哎呀,我想我已经解决了,我可以将白色灰色边框 xml 的顶部从 11dp 更改为 1 dp 或 sth 。感谢您的回答。


推荐阅读