我的问题是BottomSheetDialogFragment没有使用黑暗主题。我可以从OnCreateView手动更改主题,但它会破坏bottomomsheetdialog的动画,并且根视图正在消失。需要帮助。
public class FilterBottomSheetFragment : BottomSheetDialogFragment
{
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
//if (ThemeService.GetTheme(Context) == ThemeService.THEME_LIGHT)
//{
// inflater.Context.SetTheme(Resource.Style.AppTheme_Light);
//}
//else if (ThemeService.GetTheme(Context) == ThemeService.THEME_DARK)
//{
// inflater.Context.SetTheme(Resource.Style.AppTheme_Dark);
//}
return inflater.Inflate(Resource.Layout.filter_bottomsheet_dialog_alternate, container, false);
}
}
这就是我从mainActivity调用dialogfragment的方法;
FilterBottomSheetFragment filterBottomSheetFragment = new FilterBottomSheetFragment();
filterBottomSheetFragment.Show(SupportFragmentManager, "filterBottomSheetFragment");
活动继承自BaseActivity。
public class BaseActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (ThemeService.GetTheme(this) == ThemeService.THEME_LIGHT)
{
SetTheme(Resource.Style.AppTheme_Light);
}
else if (ThemeService.GetTheme(this) == ThemeService.THEME_DARK)
{
SetTheme(Resource.Style.AppTheme_Dark);
}
}
}