android - setlayoutParams() throws an exception -


i'm working on subclass extends relativelayout, , have onscalegesturelistener. want when scale on view, height of change(it's scalaing, resizing object). takes me exception don't know how can interprete it.

my code is:

public class simpleonscalegesturelistener extends simpleonscalegesturelistener {     @override     public boolean onscale(scalegesturedetector detector) {         tmpscale = detector.getcurrentspan() / detector.getpreviousspan();         log.d("debug", ".getcurrentspan() "+detector.getcurrentspan());         log.d("debug", ".getpreviousspan() "+detector.getpreviousspan());         log.d("debug", ".getscalefactor() "+detector.getscalefactor());         scaling = true;         relativelayout.layoutparams params = new layoutparams(kticketwidth, (int) (getmeasuredheight()*mscalefactor));         setlayoutparams(params);         //invalidate();         requestlayout();     return true;     }     @override     public void onscaleend(scalegesturedetector detector) {         mscalefactor = detector.getcurrentspan() / detector.getpreviousspan();         adjusttickets();         //expand animation         /*if (mscalefactor >= kminscale){             scaleanimation anim = new scaleanimation(1, 1, mscalefactor, 1);             startanimation(anim);             tmpscale=1;             adjusttickets();         } else if (mscalefactor < kminscale){             scaleanimation anim = new scaleanimation(1, 1, mscalefactor, 1);             startanimation(anim);             tmpscale = kminscale;             adjusttickets();         }         scaling = false;*/         log.d("scale", "scale have ended");     } }    

also exception takes me is:

05-19 13:10:28.943: e/androidruntime(15701): fatal exception: main 05-19 13:10:28.943: e/androidruntime(15701): java.lang.classcastexception: android.widget.relativelayout$layoutparams cannot cast android.widget.linearlayout$layoutparams 05-19 13:10:28.943: e/androidruntime(15701):    @ android.widget.linearlayout.measurevertical(linearlayout.java:655) 05-19 13:10:28.943: e/androidruntime(15701):    @ android.widget.linearlayout.onmeasure(linearlayout.java:574) 05-19 13:10:28.943: e/androidruntime(15701):    @ android.view.view.measure(view.java:15190) 

and thing don't know why happens mscalefactor changes 1.0 constantly, when changes 0.81464 or 1.28774 changes again 1.0. knows why happens?

exception shows what's problem

 android.widget.relativelayout$layoutparams cannot cast android.widget.linearlayout$layoutparams 

you trying cast linearlayout relativelayout , check xml file


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -