I created a custom view called MyDraw, this is my MyDraw code,
public class MyDraw extends View { public MyDraw(Context context) { super(context); } public MyDraw(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public MyDraw(Context context, AttributeSet attrs) { super(context, attrs); } ........................................ }
I added the view to the XML file using the package name. It is working fine. Now I want to set the height and width at runtime of MyDraw, for this I used the following code,
mMyDraw.setLayoutParams(new LayoutParams(220, 300));
but I got an exception for example
java.lang.ClassCastException: android.view.ViewGroup $ LayoutParams
How to solve this exception? please help me..
source share