【发布时间】:2021-09-27 16:53:00
【问题描述】:
我正在尝试为关闭按钮制作一个透明的背景标题。背景标题按预期工作,但是背景布局可以看到可见并且按钮也不清楚。
我正在尝试像下图这样构建
我的代码如下:
活动代码
final BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetMainStyle);
`dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
`dialog.show();
布局代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center|top"
android:orientation="vertical">
<ImageView
android:id="@+id/img_close"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:background="@android:color/transparent"
android:clickable="true"
android:forceDarkAllowed="false"
android:paddingBottom="@dimen/dimen_8"
android:src="@drawable/bottom_close"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@id/img_close"
android:background="@drawable/rounded_dialog"
app:background="@color/bkgcolor"
android:orientation="vertical">
<!-- All your required widgets here-->
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
标签: android-studio android-layout android-bottomsheetdialog