[英]set Linearlayout's background that contains BottomNavigationView to transparent in android
我有一个线性BottomNavigationView
linearlayout
来自 Material Design Library v2)
Linearlayout 的right
和left
有20dp
的Linearlayout
,因此底部导航显示为浮动,但 linearlayout background
永远不会透明,即使我将其设置为 #00ffffff 或 @null
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:id="@+id/mainActivityConstraint">
<LinearLayout
android:id="@+id/MainLinearLayoutMainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="@id/mainActivityConstraint"
app:layout_constraintBottom_toBottomOf="@id/mainActivityConstraint">
<!-- SOME CONTENT HERE, REMOVED FOR SIMPLIFICATION, HAS NO EFFECT ON LATER CODE -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:layout_marginBottom="10dp"
android:elevation="1dp"
android:background="@null">
<!-- Bottom Navigation Bar -->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:menu="@menu/bottom_navigation_menu"
app:labelVisibilityMode="unlabeled"
style="@style/BottomNavigationCustomStyle"
android:background="@drawable/rounded_bottomnavigation_shape"
android:padding="10dp"/>
<!-- End of Bottom Navigation Bar -->
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
白色来自某些底层视图 - LinearLayout的父级(祖父母等)或不在祖先链中但位于LinearLayout下的另一个视图。
使用布局检查器查看您的布局以确定罪魁祸首。 一旦确定,您就可以采取措施获得您想要的透明度。
试试这个代码(线性布局)...
android:background="@android:color/transparent"
代替
android:background="@null"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.