【发布时间】:2021-07-14 14:38:54
【问题描述】:
我有一个 Activity 可以滚动浏览图片列表,显示全屏图片(默认情况下,在进入 Activity 时)或下方带有一些详细信息的图片。我通过更改包含详细信息的 FrameLayout 的可见性来做到这一点。
当图片全屏时,我想看到所有的,所以我用 Glide 加载它;当我想查看详细信息时,我使用 centerCrop() 加载它。 问题是当我想重新加载图片时(从全屏模式到细节模式),imageView 保持旧布局,并在其上使用 centerCrop() (因为示例是来自同一设备的屏幕截图,它什么都不做) .
如果我只是在细节模式下滚动到下一张图片并返回,它会按预期工作。 我尝试了其他帖子中的一些东西(AsyncTast、invalidate、requestLayout),但似乎都没有。
从全屏模式向上滑动:
我得到了什么: 我想要的是:
活动的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<!-- irrelevant stuff -->
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frameLayoutZoomImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2">
<com.example.gallery_app.customViews.ZoomImageView
android:id="@+id/fullscreen_ImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<!-- a layout on top of the ImageView that contains some hidden buttons-->
</FrameLayout>
<FrameLayout
android:id="@+id/detail_split_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3">
<include
layout="@layout/activity_image_detail"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</FrameLayout>
</LinearLayout>
【问题讨论】:
标签: android android-layout imageview crop image-resizing