Can someone please explain why this statement works perfectly well:
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo);
and th
Its probably too late to answer but try using the code in onCreate of the fragment as
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
}
Calling the bottomSheetDialogFragment from the activty:
var bottomFragment = ServiceOtpVerficationFragment()
bottomFragment.setStyle(BottomSheetDialogFragment.STYLE_NO_TITLE,R.style.BottomSheetTheme)
bottomFragment.show(supportFragmentManager,"TAG")
Add this in styles.xml
<style name="BottomSheetTheme" parent="Theme.Design.Light.BottomSheetDialog"> <item name="bottomSheetStyle">@style/BottomSheetStyle</item>
</style>
<style name="BottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@android:color/transparent</item>
And In the fragment add extension as `BottomSheetDialogFragment()` to fragment class using colon.```
https://stackoverflow.com/a/24375599/2898715 it's also possible to omit the setStyle
call altogether, and define the defulat style that DialogFragments
will use throughout the whole app.
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- makes all dialogs in your app use your dialog theme by default -->
<item name="alertDialogTheme">@style/DialogTheme</item>
<item name="android:alertDialogTheme">?alertDialogTheme</item>
<item name="dialogTheme">?alertDialogTheme</item>
<item name="android:dialogTheme">?alertDialogTheme</item>
</style>
<!-- define your dialog theme -->
<style name="DialogTheme" parent="Theme.AppCompat.DayNight.Dialog.MinWidth">
<item name="android:buttonStyle">@style/button_green</item>
<item name="android:textColorHint">@color/green</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
.....
<application android:theme="@style/AppTheme">
.....
</application>
</manifest>
Try setting a parent theme like
<style name="dialog" parent="@android:style/Theme.Dialog"> Your theme attributes </style>