如何获得在我看来,在Android的加入容器的宽度 [英] How to get width of the container in which my view is added in Android

查看:107
本文介绍了如何获得在我看来,在Android的加入容器的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的LinearLayout内的ImageView对象。我设置的动画将从点X移动图像视图y的ImageView的。现在,起点应该是父容器的右上角。我的问题是,我如何得到其中的观点是present容器的尺寸。我没有看到view.getParent()的getWidth()种方法针对层次结构。

I have a ImageView object inside a LinearLayout. I'm setting an animation to the ImageView which will move image view from point x to y. Now, starting point should be right corner of parent container. My question is , how do i get the dimension of the container in which the view is present. I don't see view.getParent().getWidth() kind of method in view hierachy.

推荐答案

也许你并不需要,因为你可以使用%的动画是这样的:

Perhaps you don't need to because you can use % for animation like this:

<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="150" />

这篇关于如何获得在我看来,在Android的加入容器的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆