【问题标题】:Overlay images with Picasso用毕加索叠加图像
【发布时间】:2017-09-18 09:04:26
【问题描述】:

我有一张主要产品图片,始终显示在我的ImageView 中。现在可能有多个叠加层(与原始图像大小相同,但有很多透明区域)。

所有这些图像都来自远程 URL。例如:

Main image

Overlay

是否可以将它们全部加载到一个ImageView 中?

【问题讨论】:

  • 是的..你可以使用 FrameLayout 来做到这一点
  • 虽然使用多个 ImageView?

标签: java android imageview picasso android-image


【解决方案1】:

您可以拥有自定义的ImageViewload bitmaps with Picasso,然后在画布上绘制这些位图:

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);

    canvas.drawBitmap(bitmap1, 0, 0, null); // lower image
    canvas.drawBitmap(bitmap2, 0, 0, null); // upper image
}

【讨论】:

    【解决方案2】:

    你可以试试这个xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <ImageView
            android:id="@+id/image"
            android:layout_width="60dip"
            android:layout_height="60dip"
            android:adjustViewBounds="true"
            android:layout_centerInParent="true"
            android:scaleType="centerCrop" />
    
        <ImageView
            android:id="@+id/imagef"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_centerInParent="true"
            android:background="@drawable/ph_bg" />
    
    </RelativeLayout>
    

    【讨论】:

    • 我在问一个 ImageView
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-29
    • 2017-08-05
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    • 2014-09-26
    • 2016-12-12
    相关资源
    最近更新 更多