【发布时间】:2021-02-22 18:59:45
【问题描述】:
我在布局中声明了两个 imageViews(imageView1 和 ImageView2)。 imageView1 分配给底部,imageView2 对齐为 imageView1 的 ALIGN_BOTTOM。在代码中,执行一些操作后,imageView1 正在移动到屏幕中心。现在,imageView2 应该与 imageView1 的 ALIGN_BOTTOM 对齐。这个怎么做?我正在使用下面的布局。
<RelativeLayout
android:id="@+id/rlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:layout_alignBottom="@+id/imageView1"
android:src="@drawable/android"
android:visibility="visible" />
</RelativeLayout
【问题讨论】:
-
xml只能设置init位置。你想总是移动两个图像吗?为什么不直接移动布局呢?
-
我想动态地重新对齐视图位置。imageView1 正在移动到中心,并且从底部到中心。之后我需要将 imageView2 align_bottom 重新对齐到 imageView1
标签: android android-animation android-layoutparams