ImageView displaying in layout but not on actual device

前端 未结 9 1793
悲&欢浪女
悲&欢浪女 2020-12-13 12:50

I have an ImageView that I want to display matching the full width of the device, I realized that like this:



        
相关标签:
9条回答
  • 2020-12-13 13:18

    I had a problem with a samsung phone not displaying my drawable but it worked fine on another phone. The picture was not in any large dimensions or otherwise abnormal.

    To solve this I simply put my picture asset into a drawable subfolder instead of having it in the main drawable folder. E.g from res/drawable to res/drawable-mdpi worked for me. If you have a picture to use for everything not having a specific dpi, put it into res/drawable-nodpi. Here's a bit more about the dpi folders.

    0 讨论(0)
  • 2020-12-13 13:19

    I had the same issue and was able to solve it using following.

    My problem was that the direction of the drawable archive was wrote in the second scrCompact box.

    I copy-pasted in the up box and the issue solved.

    0 讨论(0)
  • 2020-12-13 13:22

    Alright I've tried changing the resolution of the image (cutting it in half making it 1000x130), and somehow that fixed the problem. I think Android can't render large images like that directly? I don't know, if you know more about the subject please don't hesitate to reply! Anyway, scaling down the image worked.

    0 讨论(0)
  • 2020-12-13 13:23

    For my case, I change the scale type of the image

    android:scaleType="fitXY"
    
    0 讨论(0)
  • 2020-12-13 13:26

    None of the above did the trick, it was a really big image, found this solution: In your manifest file

    <application
            //this solve it for me.
            android:hardwareAccelerated="false"
            // Add this if the previuos line didn't solve tge problem
            android:largeHeap="true"
            android:theme="@style/AppTheme">
    

    Solve it for me.

    Hope it helps someone.

    0 讨论(0)
  • For me, the problem was that I was using

    tools:src=...
    

    rather than

    android:src=...
    

    It got auto-generated trying to use an already existing template image.

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