Add floating point value to android resources/values

后端 未结 10 1945
清酒与你
清酒与你 2020-11-27 10:52

I\'m trying to add a little space between lines to my TextViews using android:lineSpacingMultiplier from the documentation:

Extra spacing

10条回答
  •  天涯浪人
    2020-11-27 11:03

    If you have simple floats that you control the range of, you can also have an integer in the resources and divide by the number of decimal places you need straight in code.

    So something like this

    356
    

    is used with 2 decimal places

    this.strokeWidthFromResources = resources_.getInteger(R.integer.strokeWidth);    
    circleOptions.strokeWidth((float) strokeWidthFromResources/ 100);
    

    and that makes it 3.56f

    Not saying this is the most elegant solution but for simple projects, it's convenient.

提交回复
热议问题