我正在尝试创建一个从View
(API 21+)中心开始的圆形显示动画.我试着用的平均值View.getLeft()
和View.getRight()
x和View.getTop()
和View.getBottom()
y的(这是什么样呢,但如果我的观点是由偏移CoordinatorLayout
,该值是错误的.我抓住一个中值OnPreDrawListener
,所以查看已测.
我发现使用View.getDrawingRect()
诀窍.
private Animator createCenteredReveal(View view) {
// Could optimize by reusing a temporary Rect instead of allocating a new one
Rect bounds = new Rect();
view.getDrawingRect(bounds);
int centerX = bounds.centerX();
int centerY = bounds.centerY();
int finalRadius = Math.max(bounds.width(), bounds.height());
return ViewAnimationUtils.createCircularReveal(view, centerX, centerY, 0f, finalRadius);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
571 次 |
最近记录: |