title: How to center text vertically in a TextView that contains text with different sizes?
body: <p>I have a TextView in my layout that contains text with different sizes:
  <a href="https://i.stack.imgur.com/XHXLu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XHXLu.png" alt="enter image description here"></a></p>
  
  <p>That's achieved with SpannableString:</p>
  
  <pre><code>SpannableString spannableString = new SpannableString("$20 Rewards");
      spannableString.setSpan(
              new AbsoluteSizeSpan(getResources().getDimensionPixelSize(R.dimen.textSize_16)), 0,
              3, 0);
  
      textView.setText(spannableString);
  </code></pre>
  
  <p>My issue is that the smaller text doesn't get centered vertically, as you can see in the pic above. I've added <code>android:gravity="center_vertical"</code> to the TextView, to no avail: </p>
  
  <pre><code>&lt;TextView
      android:id="@+id/tv_hotel_rewards"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="8dp"
      android:background="@drawable/bg_dark_blue_partial_round"
      android:gravity="center_vertical"
      android:paddingBottom="4dp"
      android:paddingEnd="8dp"
      android:paddingStart="8dp"
      android:paddingTop="4dp"
      android:textColor="@color/white"
      android:textSize="@dimen/textSize_12"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/tv_hotel_price"
      tools:text="$140 Rewards"/&gt;
  </code></pre>
  
  <p>Anyone knows how to center that vertically or if that's possible at all using a single TextView?</p>