Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems this is a bug in the API. I did tests for 4 attributes: <code>gravity</code>, <code>text</code>, <code>textSize</code> and <code>textColor</code>. Here is the code I used:</p> <pre><code>private void processAndroidAttributes(final Context context, final AttributeSet attrs) { ATTRS = new Integer[] { android.R.attr.textSize, android.R.attr.text, android.R.attr.textColor, android.R.attr.gravity }; Arrays.sort(ATTRS); do { printPermutation(ATTRS); tryApplyingStyles(context, attrs, ATTRS); ATTRS = nextPermutation(ATTRS); } while ((ATTRS = nextPermutation(ATTRS)) != null); } </code></pre> <p>The method <code>processAndroidAttributes</code> tries applying all the listed attributes and checks if they were applied or defaults were used. For each iteration I print the array <code>ATTRS</code> contents and whether the real value was used (flagged with <code>1</code>) or default was used (flagged with <code>0</code>). Here is what I get after I run the above code (every iteration prints couple of lines):</p> <pre><code>[16842901,16842904,16842927,16843087] 1111 [16842901,16842904,16843087,16842927] 1110 [16842901,16842927,16842904,16843087] 1101 [16842901,16842927,16843087,16842904] 1101 [16842901,16843087,16842904,16842927] 1100 [16842901,16843087,16842927,16842904] 1100 [16842904,16842901,16842927,16843087] 1011 [16842904,16842901,16843087,16842927] 1010 [16842904,16842927,16842901,16843087] 1011 [16842904,16842927,16843087,16842901] 1011 [16842904,16843087,16842901,16842927] 1010 [16842904,16843087,16842927,16842901] 1010 [16842927,16842901,16842904,16843087] 1001 [16842927,16842901,16843087,16842904] 1001 [16842927,16842904,16842901,16843087] 1001 [16842927,16842904,16843087,16842901] 1001 [16842927,16843087,16842901,16842904] 1001 [16842927,16843087,16842904,16842901] 1001 [16843087,16842901,16842904,16842927] 1000 [16843087,16842901,16842927,16842904] 1000 [16843087,16842904,16842901,16842927] 1000 [16843087,16842904,16842927,16842901] 1000 [16843087,16842927,16842901,16842904] 1000 [16843087,16842927,16842904,16842901] 1000 </code></pre> <p>As you see this is almost as if expecting the array to be sorted, with only several outliers. I think it is a bug in the Android API as the documentation of <a href="http://developer.android.com/reference/android/content/res/Resources.Theme.html#obtainStyledAttributes%28int,%20int%5B%5D%29"><code>obtainStyledAttributes</code></a>, does not specify to expect any ordering of the attribute ids.</p>
 

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