Tiled drawable sometimes stretches

前端 未结 8 668
余生分开走
余生分开走 2020-11-29 20:59

I have a ListView whose items have a tiled background. To accomplish this, I use the following drawable xml:



        
8条回答
  •  难免孤独
    2020-11-29 21:34

    I've just had the exact same issue except with CLAMP TileMode. I have a bitmap that I want to then just stretch away at the bottom and have it set up as an XML defined BitmapDrawable and in the Graphical Preview window all looks fine, no matter what size I make the ViewImage it draws my bitmap at the top and then repeats the last pixels to fill to the end.

    Launching the app on various SDK builds on the emulator and on my own phone all then produced a straight 'fill' type distortion which is completely useless.

    The solution turned out to simply be to re-apply the TileMode every time I changed the size of the ImageView within my code:

    ((BitmapDrawable)ascender.getDrawable()).setTileModeY(TileMode.CLAMP);
    

    Now it's all drawing fine. So yes, this looks like a bug to me.

提交回复
热议问题