Search code examples
androidandroid-constraintlayout

read layout_constraintWidth_percent value from dimens.xml


Hi I want to read the value of

app:layout_constraintWidth_percent="0.31"

from xml. as you now the value should be between 0 and 1, but it only accept integer values by default: enter image description here

this is my dimens.xml:

<resources>
<integer name="grid_cell_prec_integer">2</integer>
<fraction name="grid_cell_prec_fraction">0.31</fraction>
<item name="grid_cell_prec_float" format="float" type="dimen">0.31</item>
</resources>

only <<grid_cell_prec_integer>> is detected from dimens.xml as you can see in the previous image, what should I do?


Solution

  • @Cheticamp asnwered correctly:

    Just enter @fraction/grid_cell_prec_fraction for the value. It is just the autocomplete that is not working