Android 如何实现图像拼贴视图智能缩放而不裁剪,如谷歌Keep

Android 如何实现图像拼贴视图智能缩放而不裁剪,如谷歌Keep,android,Android,我很喜欢谷歌Keep中的图像拼贴视图 我尝试下面的库 我能做到的最好的是 如果你注意的话。有一个明显的不同。在Google Keep中,它能够更智能地缩放图像,因此不会出现图像裁剪。从缩略图中可以看到所有图像信息。没有信息丢失 我在想,你有什么想法吗,我怎样才能达到Google Keep中的效果?我已经阅读了拼贴视图的代码并试用过了 我认为解决方案的关键是在ImageView上应用正确的layout\u weight 以下面的例子为例 Image0 = 1280 x 720 Image1

我很喜欢谷歌Keep中的图像拼贴视图

我尝试下面的库

我能做到的最好的是

如果你注意的话。有一个明显的不同。在Google Keep中,它能够更智能地缩放图像,因此不会出现图像裁剪。从缩略图中可以看到所有图像信息。没有信息丢失


我在想,你有什么想法吗,我怎样才能达到Google Keep中的效果?

我已经阅读了
拼贴视图的代码并试用过了

我认为解决方案的关键是在
ImageView
上应用正确的
layout\u weight

以下面的例子为例

Image0 = 1280 x 720
Image1 = 685 x 963
Image2 = 1280 x 856

layout_weight for image 0 = 1 (since its height is the lowest)

layout_weight for image 1 = height0/height1 * width1/width0
                          = 720/963 * 685/1280 = 0.4001168224

layout_weight for image 2 = height0/height2 * width2/width0
                          = 720/856 * 1280/1280 = 0.8411214953
因此,使用以下XML

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:src="@drawable/three"
        android:adjustViewBounds="true" />

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="0.4001168224"
        android:layout_height="wrap_content"
        android:src="@drawable/two"
        android:adjustViewBounds="true"/>

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="0.8411214953"
        android:layout_height="wrap_content"
        android:src="@drawable/one"
        android:adjustViewBounds="true"/>
</LinearLayout>

看起来像这样

这就是它的样子,不应用
布局\权重

我只想说我是
CollageView
lib开发者的兄弟。我们将努力改进it@VladyslavMatviienko比你强,期待lib的改进。
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:src="@drawable/three"
        android:adjustViewBounds="true" />

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="0.4001168224"
        android:layout_height="wrap_content"
        android:src="@drawable/two"
        android:adjustViewBounds="true"/>

    <ImageView
        android:layout_width="0dp"
        android:width="0dp"
        android:layout_weight="0.8411214953"
        android:layout_height="wrap_content"
        android:src="@drawable/one"
        android:adjustViewBounds="true"/>
</LinearLayout>