使底部导航视图背景透明

毒蛙

因此我在应用中添加了底部导航视图,但是出现了问题。我希望我的底部导航视图的背景是透明的(当前是黑色的),即我希望它显示相对布局(包含btmnav)的背景的一部分,它的覆盖范围。默认情况下,我需要做的就是给相对布局一个背景,它就会起作用...但是当我这样做时,底部导航视图的背景仍然是黑色的。

菜单资源文件:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/live"
    android:icon="@drawable/ic_live_tv_black_24dp"
    android:title="Live"/>

<item
    android:id="@+id/squad"
    android:icon="@drawable/ic_team_squad_black_24dp"
    android:title="Squad"/>

<item
    android:id="@+id/schedule"
    android:icon="@drawable/ic_schedule_black_24dp"
    android:title="Schedule"/>
<item
    android:id="@+id/feed"
    android:icon="@drawable/ic_rss_feed_black_24dp"
    android:title="Feed"/>

 </menu>

布局文件中的代码

   <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"


    >



     <com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/btmnav"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemTextColor="#fff3CD70"
    app:itemIconTint="#fff3CD70"


    app:menu="@menu/bottom_navigation" />



    </RelativeLayout>

添加背景之前

添加背景后

我想要的是

用户2199860

将“ btmnav”的背景设置为具有透明alpha通道的颜色。

将其添加到您的BottonNavigationView android:background =“#00ffffff”

您还可以设置主题并在此处进行设置:

android:theme="@style/NavigationTheme"

Styles.xml

<style name="NavigationTheme" parent="AppTheme">
    <item name="itemIconTint">@android:color/white</item>
    <item name="itemTextColor">@android:color/white</item>
    <item name="android:background">#00ffffff</item>
</style>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章