Adding List view to Canvas
Hi Is it possible to add a custom list view to a canvas and ro开发者_运维问答tate the canvas to some degrees so that the list view seems to be rotated
You can do this by overriding the draw() method in a ListView subclass, but if the change is minor, it actually may be easiest to simply apply a rotation animation such as this one:
RotateAnimation anim = new RotateAnimation(0f, 3,0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setFillAfter(true);
getListView().startAnimation(anim);
Note that this uses the 2.3-and-below compatible animation framework (not the newer 3.0+ only framework), which means that the view isn't really rotated, it only looks rotated -- this means clicks still register as if the list was in its original position, which for changes more than a few degrees will noticeably mess up drag/scroll/click interactions (in which case you'll want to go with actually overriding draw(Canvas canvas)
in a custom ListView subclass and apply the necessary transformations).
精彩评论