我创建了一个 BottomSheetFragment。一切都很好,除了底部表格的标题没有变得透明。有没有办法让背景透明,就像正常的 bottomsheetFragment 一样。我尝试将父背景设置为透明,但它根本不起作用。
<android.support.constraint.ConstraintLayout 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="wrap_content"
android:id="@+id/layoutContainer"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/immediateParent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.makeramen.roundedimageview.RoundedImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView"
android:layout_width="@dimen/hundrad_twenty"
android:layout_height="@dimen/hundrad_twenty"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/sixty"
app:riv_border_color="@color/transparent"
app:riv_corner_radius="@dimen/twenty"
app:riv_mutate_background="true"
app:riv_oval="false" />
<ImageView
android:layout_width="@dimen/thirty"
android:layout_height="@dimen/thirty"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/hundred_fifty"
android:layout_marginRight="100dp"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
我已经厌倦了这个。
ConstraintLayout layoutContainer;
RelativeLayout immediateParent;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = null;
view = inflater.inflate(R.layout.bottom_sheet_dialog, container);
ButterKnife.bind(this, view);
//parent layout transparent not working
layoutContainer.setBackground(getResources().getDrawable(R.color.transparent));
immediateParent.setBackground(getResources().getDrawable(R.color.transparent));
//view transparent
view.setBackgroundColor(getResources().getColor(R.color.transparent));
return view;
}