title: Android Cardview background color with cornerradius
body: <p>I have a Cardview with a textview in it. Here's the xml</p>
  
  <pre><code>&lt;androidx.cardview.widget.CardView
          android:id="@+id/cardViewLabel"
          android:layout_width="match_parent"
          android:layout_height="80dp"
          app:cardCornerRadius="15dp"
          android:minHeight="80dp"
          android:layout_margin="10dp"
          &gt;
  
          &lt;TextView
              android:id="@+id/textView"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_gravity="center"
              android:layout_margin="10dp"
              android:autoSizeMaxTextSize="100sp"
              android:autoSizeMinTextSize="12sp"
              android:autoSizeStepGranularity="2sp"
              android:autoSizeTextType="uniform"
              android:maxLines="2"
              android:text="PLACEHOLDER"
              android:textAlignment="center"
              app:autoSizeMaxTextSize="100sp"
              app:autoSizeMinTextSize="12sp"
              app:autoSizeStepGranularity="2sp"
              app:autoSizeTextType="uniform" /&gt;
      &lt;/androidx.cardview.widget.CardView&gt;
  </code></pre>
  
  <p>And I want to programmatically change the background color of the cardview. I use the following code</p>
  
  <pre><code>cardViewLabel!!.setCardBackgroundColor(newColor)
  </code></pre>
  
  <p>But the result of this code is like this</p>
  
  <p><a href="https://i.stack.imgur.com/ixVcE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ixVcE.png" alt="real view"></a></p>
  
  <p>While when I put a color in the xml file, it looks like this
  <a href="https://i.stack.imgur.com/LiFz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LiFz8.png" alt="how it should look"></a></p>
  
  <p>As you can see, doing it programatically does something weird with the inner TextView. And when I use this piece of code</p>
  
  <pre><code>cardViewLabel!!.setBackgroundColor(newColor)
  </code></pre>
  
  <p>then the color is consistent in the cardview (i.e. the textview adapts with it), but then the corner of the cardview is gone.
  So how can I set the background color of a CardView programmatically while keeping the radius?</p>
  
  <p><strong>EDIT</strong>
  The problem seems to be only when <code>newColor</code> has a transparant alpha channel. In my case, the alpha value is about 100. Solid colors do not have this problem</p>