1

我一直试图获得如下期望的结果,但徒劳无功。我需要将图像视图屏蔽为文本,以使图像视图看起来像文本,但仍可用作图像视图,以便我可以在其中使用缩放功能。

在此处输入图像描述

图像不应超出文本边框。我有 Glide-Transformations 和其他一些,但它没有锻炼。文本是动态的,可以用任何字母或单词替换。

编辑

这是一个代码片段:

Glide.with(this).load(R.drawable.eagle).override(width, height).bitmapTransform(new CenterCrop(this),

new MaskTransformation(mContext, R.drawable.mask_e)).into(Imageview);
4

1 回答 1

-1

要向 ImageView 添加文本,您可以执行以下操作:

<RelativeLayout> 
    <ImageView
        android:id="@+id/myImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/myImageSouce" />

    <TextView
        android:id="@+id/myImageViewText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/myImageView"
        android:layout_alignTop="@+id/myImageView"
        android:layout_alignRight="@+id/myImageView"
        android:layout_alignBottom="@+id/myImageView"
        android:layout_margin="1dp"
        android:gravity="center"
        android:text="Hello"
        android:textColor="#000000" />
 </RelativeLayout>

PS。仅适用于 RelativeLayout

于 2016-03-14T05:42:15.647 回答