私のxmlレイアウトでこのコードを使用しています。以下のレイアウトといくつかの画像を追加しました
......
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/notes_container_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
.......
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/add_note_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:backgroundTint="@color/colorPrimary"
app:layout_anchor="@id/bottomAppBar"
app:srcCompat="@drawable/ic_add_black_24dp"
tools:ignore="VectorDrawableCompat" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="@color/colorPrimary"
app:hideOnScroll="false"
app:menu="@menu/appbar_menu"
app:navigationIcon="@drawable/ic_menu" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
BottomAppbarの高さは、画像に示すようにレイアウト全体を占めています
問題はの次元ではありませんBottomAppBar
。
親レイアウトの寸法または位置を確認します。
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/notes_container_layout"
android:layout_height="wrap_content"
BottomAppBar
右の高さが、持っているCoordinatorLayout
用途をandroid:layout_height="wrap_content"
。
の高さを変更するCoordinatorLayout
か、で使用android:layout_gravity="bottom"
しますCoordinatorLayout
。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加