0

I want to create imageView like this below (with the focus on red background).

enter image description here

If the image gets a null data, then, imageView shows the text with split after spacing

Is that possible to do ?

Anish B.
  • 9,111
  • 3
  • 21
  • 41
Muhammad Faisal
  • 137
  • 2
  • 2
  • 12

2 Answers2

1

You can use Picaso or Glide Imageloader library, in which you can use placeholder image, placeholder image will be displayed when your image is not loaded or your data will be null.

jay shah
  • 300
  • 1
  • 8
  • i do that , but i want if image getting null data , image show text (look at picture) – Muhammad Faisal Sep 20 '19 at 03:56
  • you can do one thing, make default image with red and white with split background, then use relative or framelayout and put the textview above that image, then put one more condition if image has null data just show this whole layout with text and if data is not null then display image as it is. Thank you – jay shah Sep 20 '19 at 04:00
0

You can create a custom image as per your needs using Adobe Illustrator and Import it to Android Studio as drawable and use it as placeholder using Glide

Code Example

Glide.with(fragment)
  .load(url)
  .error(R.drawable.placeholder)
  .listener(new RequestListener<String, DrawableResource>() {
            public boolean onException(Exception e, String model, Target<DrawableResource> target, boolean isFirstResource) {
                // Hide ImageView and Display TextView
                return false;
            }

            public boolean onResourceReady(DrawableResource resource, String model, Target<DrawableResource> target, boolean isFromMemoryCache, boolean isFirstResource) {
                // Hide TextView and Display ImageView
                return false;
            }
        })
  .into(view);
  • i was do that , but i want if image getting null data , image show as text (look at picture). – Muhammad Faisal Sep 20 '19 at 04:00
  • You can use Glide Request Listener and If onLoadFailed() is called you can hide the ImageView and display your custom TextView ( @jay shah answer). **Refer the link** [link](https://stackoverflow.com/questions/47380419/check-image-is-loaded-imageurl-by-glide) – Aravinth Velusamy Sep 20 '19 at 04:08