我在 LinearLayout
中有一个 ImageView
对象。我正在为 ImageView
设置动画,它将 ImageView 从 x 点移动到 y 点。现在,起点应该是父容器的右角。我的问题是,如何获得 View 所在容器的尺寸。我在 View 层次结构中没有看到 view.getParent().getWidth()
类方法。
最佳答案
试试这个:
View parent = (View)view.getParent();
int width = parent.getWidth();
关于android - 如何获取在Android中添加我的 View 的容器的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4968520/