我有 BottomSheetDialogFragment ,它需要在展开状态下打开,并且应该在向下滑动时跳过折叠状态。
问题是,我有时会遇到意想不到的行为
为什么我有时会看到这样的观点?
下面是我的代码,
@Override
public int getTheme() {
if (Build.VERSION.SDK_INT > 21) {
return R.style.BottomSheetDialogTheme;
} else {
return super.getTheme();
}
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener((DialogInterface.OnShowListener) dialog1 -> {
BottomSheetDialog d = (BottomSheetDialog) dialog1;
FrameLayout bottomSheet = (FrameLayout) d.findViewById(com.google.android.material.R.id.design_bottom_sheet);
if (bottomSheet != null) {
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
BottomSheetBehavior.from(bottomSheet).setSkipCollapsed(true);
BottomSheetBehavior.from(bottomSheet).setFitToContents(true);
BottomSheetBehavior.from(bottomSheet).setPeekHeight(1000);
}
});
return dialog;
}
Run Code Online (Sandbox Code Playgroud)
相同的风格/主题是
<style name="BottomSheetDialogTheme" parent="BaseBottomSheetDialog">
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent
</item>
</style>
<!-- set the rounded drawable as …Run Code Online (Sandbox Code Playgroud) 这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.arefin.lasttrykinvay"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'kinvey-android-2.10.5', ext:'aar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile google-http-client-1.19.0.jar
compile google-http-client-android-1.19.0.jar
compile google-http-client-gson-1.19.0.jar
compile google-http-client-jackson2-1.19.0.jar
compile gson-2.1.jar guava-18.0.jar
compile jackson-core-2.1.3.jar
compile java-api-core-2.10.1.jar
compile java-api-core-2.10.5.jar
compile kinvey-android-2.10.5.aar
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
这是错误
Error:Execution …Run Code Online (Sandbox Code Playgroud)