java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
报错原因:
ImageView image =(ImageView) findViewById(R.id.imageView1);
image.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
解决方法:
ImageView image =(ImageView) findViewById(R.id.imageView1);
报错原因:
ImageView image =(ImageView) findViewById(R.id.imageView1);
image.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
解决方法:
ImageView image =(ImageView) findViewById(R.id.imageView1);
image.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
小结:
遇到问题时,解决思路有哪些,强化下,第一理清问题环境和背景,如查看如上错误提示,马上就可以定位问题,快速解决。第二、三、四,
其实它不算是问题。为了强化这种思路,在此记录下。