我在充气
bottom_sheet_layout
. 它包含一个LinearLayout作为根元素。它有一张儿童卡。
我试过以下方法:
setting `android:background` property to
1. #00FFFFFF
2. #00000000
3. @android:color/transparent
setting the background color of LinearLayout programatically
`LinearLayout l = container.findViewById(R.id.root_element);
l.setBackgroundColor(Color.TRANSPARENT);`
这是
BottomSheet.Class
与
底部板材布局
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.bottom_sheet_layout, container, false);
LinearLayout l = container.findViewById(R.id.root_element);
l.setBackgroundColor(Color.TRANSPARENT);
return v;
}
已经满了
底部板材布局
android:id="@+id/root_element"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="16dp">
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
card_view:cardCornerRadius="4dp">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/poiName"
android:fontFamily="@font/comfortaa_bold"
android:text="@string/poiName"
android:textSize="20sp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="20dp"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:fontFamily="@font/work_sans_medium"
android:text="@string/ui_location"
android:textFontWeight="800" />
android:id="@+id/location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:fontFamily="@font/work_sans"
android:text="@string/ui_location_addr" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:src="@drawable/share"
android:scaleType="center"
card_view:backgroundTint="@color/colorPrimary" />
这是
Map Fragment
. 这里是我充气的地方
底部板材布局
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
跟着几位导游,我还是找不到
#00FFFFFF
工作方法。以编程方式将颜色设置为透明,会导致应用程序崩溃。
在前面关于StackOverflow的问题中,似乎将背景设置为使用alpha值的十六进制代码。现在我只得到一个暗淡的灰色背景。
应用程序的屏幕截图