prashant prashant - 3 months ago 7x
Android Question

How to get width of the container in which my view is added in Android

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="" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="150" />