Android: Drawable not showing up

前端 未结 7 1703
鱼传尺愫
鱼传尺愫 2021-02-06 03:46

I have a fairly simple xml file that has an image button in it. The image shows up fine on the Graphical Layout xml designer, shows up fine when I run a development build, but a

相关标签:
7条回答
  • 2021-02-06 04:14

    Well ! in my case setting MinifyEnabled false and shrinkResources false is working fine now.

    i was getting image from drawable. it was working pretty nice in debug version but after release version of apk it was showing sometime blank ImageView.

    minifyEnabled false shrinkResources true

    **

    See the Screenshots

    **

    Hope this may help anyone.

    0 讨论(0)
  • 2021-02-06 04:18

    Had the same issue and resolved it by removing all special characters. In my case it was dashes '-' in the filename:

    background-720.png => background.png.

    0 讨论(0)
  • 2021-02-06 04:22

    My situation was weird.Everything was correct until integrating FireBase Crash report to my Application.

    I just added compile 'com.google.firebase:firebase-crash:11.0.1' & DrawableLeft vanished .When i went through the xml , noticed a warning (In lined below).

    So added android:drawableStart & issue gone.

    Still I am wondering about the relation of FireBase Crash reporting to the same.

    Using left/right instead of start/end attributes Using Gravity#LEFT and Gravity#RIGHT can lead to problems when a layout is rendered in locales where text flows from right to left. Use Gravity#START and Gravity#END instead.

    Similarly, in XML gravity and layout_gravity attributes, use start rather than left. For XML attributes such as paddingLeft and layout_marginLeft, use paddingStart and layout_marginStart.

    NOTE: If your minSdkVersion is less than 17, you should add both the older left/right attributes as well as the new start/right attributes. On older platforms, where RTL is not supported and the start/right attributes are unknown and therefore ignored, you need the older left/right attributes.

    There is a separate lint check which catches that type of error. (Note: For Gravity#LEFT and Gravity#START, you can use these constants even when targeting older platforms, because the start bitmask is a superset of the left bitmask. Therefore, you can use gravity="start" rather than gravity="left|start".)

    0 讨论(0)
  • try to put the image in drawable-hdpi and drawable-mdpi folder depends on what device you run you app , the image is searched in these folders...

    But puting in drawable means that the image should be available everywhere, but somethimes (depends on your manifest settings) this could not be true, I mean you can turn of the compatibility mode.

    also you can try dinamically at run time to set the image to the view

    iv.setImageResource(R.drawable.somethig);
    
    0 讨论(0)
  • 2021-02-06 04:26

    Check your image size. If you're using an unnecessarily large asset when actually deployed it might just not show despite looking correct in the designer.

    0 讨论(0)
  • 2021-02-06 04:29

    One of the reason is

    If you are using Vector file as a drawable left or right then you have to use .

    android.support.v7.widget.AppCompatButton

    Instead Of

    Button

    Simple View like Button,Textview doesn't support Vector file as a Drawable left right in my case

    0 讨论(0)
提交回复
热议问题