顶部边框材料底部应用栏Android

时间:2020-04-21 23:44:21

标签: android kotlin material-design android-bottomappbar

我想在com.google.android.material.bottomappbar.BottomAppBar的顶部放置一个边框。 bottom 我试图将此drawable作为background应用于我的BottomAppBar

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:left="-5dp"
        android:right="-5dp"
        android:bottom="-5dp">
        <shape android:shape="rectangle" >
            <solid android:color="@android:color/white" />

            <stroke
                android:width="1.8dp"
                android:color="@color/midGreen" />
        </shape>
    </item>

</layer-list>

但是没有用。

我的BottomAppBar的实现方式是:

<androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/clBottom"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.bottomappbar.BottomAppBar
            android:background="@drawable/background_border_mid_green_top"
            style="@style/Widget.MaterialComponents.BottomAppBar"
            android:id="@+id/bottomAppbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/first_menu_item"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_weed_shop_2"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/second_menu_item"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <ImageView
                    android:id="@+id/second_menu_item"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_weed_stats"
                    app:layout_constraintBottom_toBottomOf="@+id/first_menu_item"
                    app:layout_constraintEnd_toStartOf="@+id/placeholder"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toEndOf="@+id/first_menu_item" />

                <View
                    android:id="@+id/placeholder"
                    android:layout_width="70dp"
                    android:layout_height="0dp"
                    android:visibility="invisible"
                    app:layout_constraintBottom_toBottomOf="@+id/first_menu_item"
                    app:layout_constraintEnd_toStartOf="@+id/third_menu_item"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toEndOf="@+id/second_menu_item"
                    app:layout_constraintTop_toTopOf="@+id/first_menu_item" />

                <ImageView
                    android:id="@+id/third_menu_item"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_edibles"
                    app:layout_constraintBottom_toBottomOf="@+id/first_menu_item"
                    app:layout_constraintEnd_toStartOf="@+id/fourth_menu_item"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toEndOf="@+id/placeholder" />

                <ImageView
                    android:id="@+id/fourth_menu_item"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_logo_v2"
                    app:layout_constraintBottom_toBottomOf="@+id/first_menu_item"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toEndOf="@+id/third_menu_item"
                    app:layout_constraintTop_toTopOf="@+id/first_menu_item" />

            </androidx.constraintlayout.widget.ConstraintLayout>

        </com.google.android.material.bottomappbar.BottomAppBar>

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            app:backgroundTint="@color/midGreen"
            app:borderWidth="2dp"
            app:layout_anchor="@id/bottomAppbar"
            android:id="@+id/fab"
            android:backgroundTint="@color/mainGreen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:src="@drawable/ic_plus_without_circle_white"
            android:layout_marginBottom="30dp"
            android:clickable="true"
            app:tint="@android:color/white"
            android:focusable="true"
            app:rippleColor="@android:color/white" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

如果您需要我的代码的更多内容,请不要犹豫。

0 个答案:

没有答案