Error android.widget.LinearLayout.measureHorizontal LinearLayout.java

Code with error:

ImageView imgV = (ImageView)findViewById(R.id.myView);
        imgV.setLayoutParams(new ViewGroup.LayoutParams(
        		ViewGroup.LayoutParams.WRAP_CONTENT,
        		0));

If you get error try this code:

        ViewGroup.LayoutParams layoutParams = imgV
				.getLayoutParams();
		layoutParams.height = 0;
		imgV.setLayoutParams(layoutParams);

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:659)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)

This entry was posted in Android Examples Code, Bugs, warnings, errors and tagged , , . Bookmark the permalink.


Comments are closed.



3,830 views