【发布时间】:2018-09-10 05:03:02
【问题描述】:
我有一个包含许多图像的 RecyclerView。当长按图像时,我会取消隐藏 RelativeView(通过 setVisibility(View.VISIBLE))以在 ImageView 中显示图像的“预览”,直到释放长按,此时我再次隐藏预览。目前,这按预期工作,只是预览总是显示在屏幕上的同一位置。
有没有办法将预览锚定到用户点击的位置?理想情况下,我希望底角与用户长按的位置(或至少底边)对齐。这是我的预览目前的样子:
这是 RecyclerView 和预览容器布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Recyclerview -->
<com.sometimestwo.moxie.MultiClickRecyclerView
android:id="@+id/recycler_zoomie_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Preview container that gets hidden/unhidden-->
<RelativeLayout
android:id="@+id/hover_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:visibility="gone">
<TextView
android:id="@+id/hover_view_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorBgBlackTint"
android:gravity="center"
android:textColor="@color/colorWhite"
android:visibility="visible" />
<ImageView
android:id="@+id/hover_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/hover_view_title"
android:background="@color/colorBgBlackTint"
android:visibility="visible" />
</RelativeLayout>
</FrameLayout>
【问题讨论】:
标签: android android-layout android-imageview android-relativelayout