1

I have been trying to get the desired result as below but in-vain. I need to mask an imageview into text so that the imageview looks like text but still works as an imageview such that i can use zoom functionality in it.

enter image description here

The image should not overflow beyond the text border. I have out Glide-Transformations and some others but it didn't workout.The text is dynamic and can be replaced by any letters or words.

EDIT

Here's a code snippet:

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

new MaskTransformation(mContext, R.drawable.mask_e)).into(Imageview);
AL.
  • 36,815
  • 10
  • 142
  • 281
hablema
  • 540
  • 1
  • 5
  • 17
  • Can you provide the code snippets you have implemented so far? – AL. Mar 14 '16 at 04:54
  • @sept `Glide.with(this) .load(R.drawable.eagle) .override(width, height) .bitmapTransform(new CenterCrop(this), new MaskTransformation(mContext, R.drawable.mask_e)) .into(Imageview);` This works but when Imageview becomes SubsamplingScaleImageView it breaks. – hablema Mar 14 '16 at 07:04

1 Answers1

-1

To add a text to your ImageView you can do this:

<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. Only works inside a RelativeLayout

  • Please read the requirement carefully. It's not adding a text on an image. Its wraping an image in the shape of a text. – hablema Mar 14 '16 at 07:01
  • i have found the solution here...http://stackoverflow.com/questions/14801075/android-how-to-apply-mask-on-imageview?rq=1 –  Mar 14 '16 at 09:33
  • I have checked it out . But the end result should not be a combined bitmap. Please check the code snippet i have attached. It's similar to what i want. – hablema Mar 15 '16 at 10:54