How can I work around Android issue 9161, where bottomRightRadius and bottomLeftRadius are swapped?

前端 未结 5 1971
南方客
南方客 2020-12-05 14:35

My goal:

\"Figure
Figure 1: The Goal

So, before I knew about the issue, her

5条回答
  •  鱼传尺愫
    2020-12-05 15:28

    A better solution:

    • Create another folder values-12
    • Create dimensions.xml file under values-12.
    • Put 2 dimension properties in values-12/dimensions.xml for the bottom left, and bottom right corner radius.
    • Put 2 dimension properties in values/dimensions.xml for bottom left, and bottom right corner radius values, but remember to flip them.

    Use the dimension values when assigning corner radius instead of hardcoding them in your drawables. When a pre 3.1 loads, it will use the reversed corner radius values under folder values. When 3.1+ loads, it will use correct corner radius values under folder values-12.

    Why is this better? You don't need to duplicate drawable code. Now you can change any code not related to corner radiuses without having to update 2 or more places.

提交回复
热议问题