i have problem with my BottomSheetDialog, i want to put my image on the cardview of BottomSheetDialog, that work in AndroidStudio Design editor but not in my device. Do you have any solution ?
These are my results on this picture
card_view:cardElevation="0dp"
didn't work and white background behind)I want to remove this white background and put image on the top
xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:id="@+id/fragment_character_menu_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="72dp"
app:cardBackgroundColor="@color/secondary"
card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:layout_marginStart="140dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lorem ipsum"
android:textColor="@color/secondary_font"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/frameLayout"
app:layout_constraintStart_toEndOf="@+id/imageView" />
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="32dp"
android:alpha="0.05"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView" />
</LinearLayout>
<LinearLayout
android:id="@+id/fragment_character_bottom_sheet_rename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingStart="32dp"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
app:srcCompat="@drawable/ic_edit_line"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/secondary_font"
android:layout_marginLeft="16dp"
android:text="Rename"/>
</LinearLayout>
<LinearLayout
android:id="@+id/fragment_character_bottom_sheet_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingStart="32dp"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
app:srcCompat="@drawable/ic_round_edit"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:textColor="@color/secondary_font"
android:text="Edit"/>
</LinearLayout>
<LinearLayout
android:id="@+id/fragment_character_bottom_sheet_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingStart="32dp"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
app:srcCompat="@drawable/ic_share"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/secondary_font"
android:layout_marginLeft="16dp"
android:text="Share"/>
</LinearLayout>
<LinearLayout
android:id="@+id/fragment_character_bottom_sheet_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingStart="32dp"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
app:srcCompat="@drawable/ic_trashcan_solid"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/secondary_font"
android:layout_marginLeft="16dp"
android:text="Delete"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imageView"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_margin="8dp"
app:strokeWidth="4dp"
app:srcCompat="@mipmap/ic_launcher"
app:shapeAppearanceOverlay="@style/ImageView.Corner.Round"
/>
</RelativeLayout>
</RelativeLayout>
and how I Implement it:
BottomSheetDialog mBottomSheetDialog = new BottomSheetDialog(mMainActivity);
View sheetView = mMainActivity.getLayoutInflater().inflate(R.layout.fragment_character_bottom_sheet, null);
mBottomSheetDialog.setContentView(sheetView);
mBottomSheetDialog.show();
Thanks for all tips and idea to help me.
[Edit] I have solve my problem here: https://stackoverflow.com/a/77202147/22654090 but if anyone know how to put border of image to transparent can say to me
I've solved my problem! I simply created a custom style for the BottomSheetDialog to remove the white background:
BottomSheetDialog mBottomSheetDialog = new BottomSheetDialog(mMainActivity, R.style.SheetDialog);
<style name="SheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:colorBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.3</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
</style>
and added elevation to my image to put it on top of the cardview
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imageView"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_margin="8dp"
android:elevation="4dp"
app:strokeWidth="4dp"
app:srcCompat="@mipmap/ic_launcher"
app:shapeAppearanceOverlay="@style/ImageView.Corner.Round"
/>
Goodbye !