title: Android selector changes color but not size
body: <p>I am trying to use a selector to implement a simple dot indicator for a ViewPager. </p>
  
  <p>The dots are supposed to change color and size when the page is changed, but they only change color, while the size stays the same.</p>
  
  <p>The selector:</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:state_selected="true"&gt;
          &lt;shape android:shape="oval"&gt;
               &lt;size
                 android:height="12dp"
                 android:width="12dp"/&gt;
              &lt;solid android:color="@color/highlight"/&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;shape android:shape="oval"&gt;
              &lt;size
                android:height="6dp"
                android:width="6dp"/&gt;
              &lt;solid android:color="@color/light_grey"/&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>which is used in a layout</p>
  
  <pre><code>&lt;ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="@dimen/margin_2x"
    android:src="@drawable/dot_selector"&gt;
  &lt;/ImageView&gt;
  </code></pre>
  
  <p>which is used in onCreate() to show the initial state:</p>
  
  <pre><code>for (int i = 0; i &lt; mPagerAdapter.getCount(); i++) {
      getLayoutInflater().inflate(R.layout.dot_indicator, viewPagerCountDots);
  }
  viewPagerCountDots.getChildAt(0).setSelected(true);
  </code></pre>
  
  <p>This looks as expected:</p>
  
  <p><a href="https://i.stack.imgur.com/IERji.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IERji.png" alt="enter image description here"></a></p>
  
  <p>But when I change the selector state when the page is changed like this...</p>
  
  <pre><code>@Override
  public void onPageSelected(int position) {
      for (int i = 0; i &lt; mPagerAdapter.getCount(); i++) {
          viewPagerCountDots.getChildAt(i).setSelected(i == position);
      }
  }
  </code></pre>
  
  <p>..it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/65122.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/65122.png" alt="enter image description here"></a></p>
  
  <p>Invalidating the child or the ViewGroup does not do anything. Any clue what is going wrong here?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Calling requestLayout on the child fixes it, as suggested by <a href="https://stackoverflow.com/a/38179716/1009684" title="Bartek">Bartek Lipinski</a></p>
  
  <pre><code>@Override
  public void onPageSelected(int position) {
      for (int i = 0; i &lt; mPagerAdapter.getCount(); i++) {
          View dotView = viewPagerCountDots.getChildAt(i);
          dotView.setSelected(i == position);
          dotView.invalidate();
          dotView.requestLayout();
      }
  }
  </code></pre>