I have an app in which i have a MainActivity which contains a fragment that extends BottomSheetDialogFragment. What I want to set fragment theme but it remains same.Pls help
Code for fragment that extends BottomSheetDialogFragment:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="@style/CoffeeDialog">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_Camera"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginTop="10dp"
android:src="@drawable/amazon"
app:civ_border_color="@color/textColor"
app:civ_border_width="5dp"
app:civ_fill_color="@color/colorPrimary" />
<android.support.v7.widget.RecyclerView
android:id="@+id/notification_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="30dp">
</FrameLayout>
here i am using android:theme="@style/CoffeeDialog" but it's not working.
Code for theme:-
<style name="CoffeeDialog" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:windowCloseOnTouchOutside">false</item>
<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>
Note:- I only want to change fragment theme, not MainActivity.
public class CustomDialogFragment extends BottomSheetDialogFragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super. onCreate(savedInstanceState); setStyle(STYLE_NORMAL, R. style.
Bottom sheets are set to STATE_COLLAPSED at first. Call BottomSheetBehavior#setState(STATE_EXPANDED) if you want to expand it. Note that you cannot call the method before view layouts.
Disable drag of BottomSheetDialogFragment It can also be disabled by overriding onStateChanged() . This will set the expanded state even if user drags the view.
Showing the DialogFragment It is not necessary to manually create a FragmentTransaction to display your DialogFragment . Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.
In your fragment add your theme with the getTheme
method
like this:
override fun getTheme(): Int {
return R.style.CustomBottomSheetDialog
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With