prashant prashant - 1 year ago 77
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.

Answer Source

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" />

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download