我面临一个特定的问题。我有一个 bottomSheet,我想在 TopLeft 和 TopRight 角上放置一个半径。除非 bottomSheet.state 为STATE_EXPANDED
. 所以我找到了这个解决方案
@SuppressLint("RestrictedApi", "VisibleForTests")
override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog {
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
bottomSheetDialog.behavior.disableShapeAnimations()
return bottomSheetDialog
}
但问题是:在我的bottomSheet 中,我有一个EditText 和一个按钮。使键盘在按钮下方,我必须在我的onCreateDialog
方法中添加这行代码
bottomSheetDialog.behavior.state = STATE_EXPANDED
所以当我添加它时,由于某种原因,角落不再是圆的......
在这里你可以找到我当前的代码:
@SuppressLint("RestrictedApi", "VisibleForTests")
override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog {
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
bottomSheetDialog.behavior.disableShapeAnimations()
bottomSheetDialog.behavior.state = STATE_EXPANDED
return bottomSheetDialog
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NORMAL, R.style.BottomSheetStyle)
}
在这里我的Style
<style name="BottomSheetStyle" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
你知道我能做些什么来完成这项工作吗?bottomSheetDialog.behavior.disableShapeAnimations()