android - TranslateAnimation with RelativeLayout and SurfaceView -
straight question, have surfaceview
inside relativelayout
follows:
<relativelayout android:id="@+id/surfaceframe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff000000" android:visibility="visible" > <surfaceview android:id="@+id/surface" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:visibility="visible" /> </relativelayout>
i have requirement make relativelayout
along surfaceview
move. easy.
mplayerframe.settranslation(distance);
this mplayerframe
variable relativelayout.
however, have support api level 10. client insists on doing so. came chunk of code after browsing here , elsewhere.
translateanimation anim = new translateanimation(0,0,distance,distance); anim.setfillafter(true); anim.setduration(0); mplayerframe.startanimation(anim);
with above code, see mplayerframe
moving playback (mplayerview
, surfaceview
) apparently did not move @ all.
so far have tried followings:
setting animation
mplayerview
mplayerview.startanimation(anim);
setting offsettopandbottom
mplayerview.offsettopandbottom(distance);
it move using this, @ faster rate rate of
mplayerframe
moving.
so summarize, have surfaceview
inside relativelayout
, want move relativelayout
along surfaceview
child around. achievable using api level 11+ had support api level 10 well.
thank you,
if have difficult old animation framework, use great library add compatibility of api11 objectanimator old android platform:
there differences between library , new one, fact new move object new position , library show image of it, recommend split code according api level.
Comments
Post a Comment