Android 底部工作表动画在某些设备中不起作用
我正在使用kotlin创建底部工作表对话框,它工作得很好,但在一些设备中,从底部到顶部的动画不工作- 我的XML代码 1。content\u bottom\u sheet.xmlAndroid 底部工作表动画在某些设备中不起作用,android,animation,bottom-sheet,android-bottomsheetdialog,Android,Animation,Bottom Sheet,Android Bottomsheetdialog,我正在使用kotlin创建底部工作表对话框,它工作得很好,但在一些设备中,从底部到顶部的动画不工作- 我的XML代码 1。content\u bottom\u sheet.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bottom_sheet_rounded"
app:behavior_hideable="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:layout_alignParentBottom="true"
app:behavior_peekHeight="@dimen/_340sdp"
>
////
///
</RelativeLayout>
但在一些设备中,它的动画(从下到上)没有显示。你可以建议我的代码,使其从下到上与动画的方式来改变
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bottom_sheet_rounded"
>
///
///
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp">
<include
android:id="@+id/bottomSheetDialog"
layout="@layout/content_bottom_sheet"></include>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetDialog)
(bottomSheetBehavior as BottomSheetBehavior<View>?)?.state = BottomSheetBehavior.STATE_HIDDEN
(bottomSheetBehavior as BottomSheetBehavior<View>?)?.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
when (newState) {
BottomSheetBehavior.STATE_EXPANDED -> {
}
BottomSheetBehavior.STATE_COLLAPSED -> {
}
BottomSheetBehavior.STATE_HALF_EXPANDED -> {
}
BottomSheetBehavior.STATE_HIDDEN -> {
}
BottomSheetBehavior.STATE_HALF_EXPANDED->{
}
}
}
override fun onSlide(bottomSheet: View, slideOffset: Float) {
}
})
if(bottomSheetBehavior?.state != BottomSheetBehavior.STATE_STATE_COLLAPSED){
bottomSheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
}