Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a solution:</p> <pre><code>&lt;resources&gt; &lt;item name="text_line_spacing" format="float" type="dimen"&gt;1.0&lt;/item&gt; &lt;/resources&gt; </code></pre> <p>In this way, your float number will be under @dimen. Notice that you can use other "format" and/or "type" modifiers, where format stands for: </p> <p>Format = enclosing data type:</p> <ul> <li>float</li> <li>boolean</li> <li>fraction</li> <li>integer</li> <li>...</li> </ul> <p>and type stands for:</p> <p>Type = resource type (referenced with R.XXXXX.name):</p> <ul> <li>color</li> <li>dimen</li> <li>string</li> <li>style</li> <li>etc...</li> </ul> <p>To fetch resource from code, you should use this snippet:</p> <pre><code>TypedValue outValue = new TypedValue(); getResources().getValue(R.dimen.text_line_spacing, outValue, true); float value = outValue.getFloat(); </code></pre> <p>I know that this is confusing (you'd expect call like <code>getResources().getDimension(R.dimen.text_line_spacing)</code>), but Android <code>dimensions</code> have special treatment and pure "float" number is not valid dimension.</p> <hr> <p>Additionally, there is small "hack" to put float number into dimension, but be <strong>WARNED</strong> that this is <strong>really hack</strong>, and you are risking chance to lose float range and precision.</p> <pre><code>&lt;resources&gt; &lt;dimen name="text_line_spacing"&gt;2.025px&lt;/dimen&gt; &lt;/resources&gt; </code></pre> <p>and from code, you can get that float by</p> <pre><code>float lineSpacing = getResources().getDimension(R.dimen.text_line_spacing); </code></pre> <p>in this case, value of <code>lineSpacing</code> is <code>2.024993896484375</code>, and not <code>2.025</code> as you would expected.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload