我已将位图设置为 ImageView,然后想为宽度和高度设置 wrap_content。
imgSubsegment = (ImageView) findViewById(R.id.subsegment);
ViewGroup.LayoutParams imageViewParams = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
......................................
imgSubsegmentSensor.setImageBitmap(bmpSubsegmentSensor);
imgSubsegmentSensor.setLayoutParams(imageViewParams);
它在给java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.ViewGroup$MarginLayoutParams
我的代码有什么问题?怎么解决?