Understanding Android's <layer-list>

前端 未结 2 1581
余生分开走
余生分开走 2020-11-28 05:36

I don\'t understand how the layer-lists work. I read the official documentation with some examples but it does not work for me like expected. I want four squares which shoul

相关标签:
2条回答
  • 2020-11-28 06:13

    The values for left, top, right and bottom are measured from their respective edge.

    So left=0dp, top=0dp, bottom=0dp & right=50dp will give you a rectangle that is (match_parent - 50dp) wide and not 50dp wide. Therefore larger values for "right" will actually give you a smaller rectangle.

    The same would apply to the other value, but these would behave as expected in most cases, its just "right" that might cause confusion.

    0 讨论(0)
  • 2020-11-28 06:27

    Either you use px instead of dp or multiply all dimensions by 10.

    I'm ashamed to admit that I don't exactly know WHY this is happening but my guess is that it has something to do with densities where 1dp is a floating px value and the ImageView is scaled up.

    Expert answer is welcomed :)

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