I'm a newbie to Android programming.
I'm building an app with sharing feature as the first picture.
When the user shares a file, I want to show the bottom sheet menu as dialog like the 2nd picture.
But now the activity is covering the main screen like 3rd picture.
How can I hide the activity or make it transparent (result like 2nd image)?
Thank you for your help!!!
https://material.io/components/sheets-bottom/android
(I made these images by Photoshop)
How I added my activity to the Android sharing sheet in AndroidManifest.xml
<activity
android:name=".ActivityShare"
android:exported="true"
android:label="@string/ActivityShareName">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
How I created the bottom sheet in ActivityShareSheet.kt
class ModalBottomSheet : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.activity_share_sheet, container, false)
companion object {
const val TAG = "ModalBottomSheet"
}
}
open class ActivityShareSheet : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val modalBottomSheet = ModalBottomSheet()
modalBottomSheet.show(supportFragmentManager, ModalBottomSheet.TAG)
}
}
I just found a simple solution: Creating a transparent theme for the activity
But note that the theme must be based on the Theme.AppCompat family