【发布时间】:2022-01-05 21:57:10
【问题描述】:
我正在尝试制作一个底部导航栏,其中中间的图标是我自己的图标,应该可以点击并且应该适合 like this
在菜单目录中,我创建了bottom_navigation.xml,其中负责我想要的图标的行是:
<item
android:id="@+id/park"
android:icon="@drawable/ic_parkcenter"
android:title="Park here"/>
在我的 maps_activity.xml(我希望显示此内容的主页)中,我使用它:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_height="75dp"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:id="@+id/bottom_nav"
map:menu="@menu/bottom_navigation" />
这就是我get的结果
我想把它作为图像视图而不是一个项目,但遗憾的是它在菜单中不起作用。我应该如何在这里进行? 提前致谢!
编辑:我的 acitivty_maps.xml,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Can be ignored -->
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
<!-- Can be ignored -->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/purple_500"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
map:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav_left"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:layout_gravity="bottom"
map:menu="@menu/bottom_navigation"
android:background="@color/purple_500"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom">
<!-- For the image i want in the middle -->
<ImageView
android:id="@+id/parkcenter"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:src="@drawable/ic_parkcenter" />
</LinearLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav_right"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:layout_gravity="bottom"
map:menu="@menu/bottom_navigation"
android:background="@color/purple_500"/>
<!-- Can be ignored -->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/parking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center"
android:layout_margin="16dp"
android:contentDescription="@string/parking"
android:src="@drawable/ic_parking" />
</FrameLayout>
</LinearLayout>
如果有帮助,这一切都在抽屉布局中!再次非常感谢!
【问题讨论】:
标签: android xml android-studio android-layout bottomnavigationview