ImagePicker
ImagePicker copied to clipboard
多选时,选择预览图片时,出现崩溃
崩溃原因:java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.View.getLayoutParams()' on a null object reference
问题部分代码: ImagePreviewBaseActivity——>onCreate()——> //因为状态栏透明后,布局整体会上移,所以给头部加上状态栏的margin值,保证头部不会被覆盖 topBar = findViewById(R.id.top_bar); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) topBar.getLayoutParams(); params.topMargin = Utils.getStatusHeight(this); topBar.setLayoutParams(params); } 手机型号:android 6.0 红米note3 还请大神抽空看看!
请确认项目中layout文件是否于jar包中的有冲突。没有正确的加载到这个layout文件导致的
我遇到的这个bug,是因为项目工程里已经有一个ImagePreviewBaseActivity然后就导致引用的布局文件错乱了,关键这个冲突的activity是另一个同事添加的,坑死找了一两天了;解决办法当然是重新命名其中一个了,要么改库的要么改自己工程的