简体   繁体   English

Android自定义视图绝对定位

[英]Android Custom View Absolute Positioning

My question is rather straightforward. 我的问题很简单。 I have a custom view (a rectangle), that will be rotated, translated, and scaled ontop of its parent view (RelativeLayout). 我有一个自定义视图(一个矩形),它将在其父视图(RelativeLayout)的顶部旋转,平移和缩放。

My question is what is the best way to handle these transformations. 我的问题是处理这些转换的最佳方法是什么。 Should I: A: Modify the CustomView's draw() and apply canvas transformations B: Modify the LayoutParams margin for left and top. 我应该:A:修改CustomView的draw()并应用画布转换B:修改左和顶部的LayoutParams边距。 C: Pursue an alternate approach, given my problem set. C:根据我的问题,采取另一种方法。

The rest of the problem set looks like this. 问题集的其余部分看起来像这样。 1. The Custom View must be able to overlap other custom views and be able to be drawn outside the bounds of its parent view. 1.自定义视图必须能够与其他自定义视图重叠,并且能够在其父视图的范围之外绘制。 2. A 4 point path is generated overtop the CustomView's drawable that represents its collision volume. 2.在CustomView的可绘制对象上方生成4点路径,以表示其碰撞体积。 This collision volume is synchronized with the rotation and translation of the View by modifying a Matrix object that is then applied on top of the volume in order to accurately handle collisions and avoid false positives. 通过修改一个Matrix对象,此碰撞体积与View的旋转和平移同步,然后将其应用于体积之上,以便准确处理碰撞并避免误报。 3. This custom view object will be animated using standard AnimationTranslate, AnimationRotate, AnimationScale functionality. 3.此自定义视图对象将使用标准的AnimationTranslate,AnimationRotate,AnimationScale功能进行动画处理。 After the animation completes the original View will be transposed to its computed location postAnimation. 动画完成后,原始视图将转置到其计算位置postAnimation。

Thank You for your time experts 谢谢您的时间专家

您可以在此处阅读有关属性动画的更多信息http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM