3 回答

TA貢獻1772條經(jīng)驗 獲得超5個贊
如果您不使用MapView,我認為您是bottom_sheet_layout在同一片段中對 Google Map + 進行充氣。如果是,我認為您的問題不是 LinearLayout 透明度,而是您插入bottom_sheet_layout到片段容器的底部,而不是地圖上方。
您可以將此布局用于您的地圖片段(androidx,但如果您使用的是 android,則非常相似)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- use this fragment for your google map -->
<fragment
android:id="@+id/google_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!-- use this fragment for your bottom_sheet class -->
<fragment
android:id="@+id/bottom_sheet"
android:layout_margin="16dp" // with this you do not need the LinearLayout root_element
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
然后,您可以使用您的CardView( 或LinearLayout)visibility來顯示或不顯示該卡。
其他布局也是可能的,比如直接使用卡片視圖而不是Fragment.

TA貢獻1860條經(jīng)驗 獲得超8個贊
我想我可以為您提供某種解決方案,您也可以嘗試看看是否可行。
在 .java文件中使用alpha 屬性
根據(jù)您的輕松程度調(diào)整值
LinearLayout l = container.findViewById(R.id.root_element);
l.setAlpha(0.4);
您也可以在 XML 文件中使用 alpha:
<LinearLayout
android:id="@+id/l1"
android:alpha="0.5"
android:layout_width="190dp"
android:layout_height="match_parent">
0.0 表示完全透明,1.0 表示完全不透明。
讓我知道是否有任何解決方案適合您。然而,在這里做更多的研究,你一定會得到一個解決方案??鞓返木幋a。

TA貢獻1804條經(jīng)驗 獲得超2個贊
嘗試背景為空。
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null">
......
</LinearLayout>
添加回答
舉報