我有一个项目,我正在为其做一个透明的底部导航栏,只有图标可见。
我从Android Studio中获取了默认的底部导航活动项目,并使导航栏的背景透明:
android:background="@android:color/transparent"
[现在有一个半透明的正方形,图标的左右两侧分别填充了8dp(顶部填充出现了16dp?)...在Nexus 5X上,图像似乎歪斜了吗?任何想法如何删除此?
这里是完整的xml代码供参考:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_dark"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@android:color/transparent"
app:itemIconTint="@android:color/black"
app:itemTextColor="@android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
因此事实证明,将以下属性添加到XML中的<BottomNavigationView />
可以解决此问题:
app:elevation="0dp"
(只需将评论中的答案放入常规答案中]