title: Why setBackgroundResource() not work in my custom view?
body: <p>I created a custom view with the following code :  </p>
  
  <pre><code>public class TestView extends LinearLayout {
      public TestView(Context context) {
          this(context, null);
      }
  
      public TestView(Context context, AttributeSet attrs) {
          this(context, attrs, 0);
      }
  
      public TestView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          initView(context);
      }
  
      private void initView(Context context) {
          LayoutInflater.from(context).inflate(R.layout.layout_test, this);
          setBackgroundResource(R.color.black);
      }
  
  }
  </code></pre>
  
  <p>layout_test.xml :</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"/&gt;
  </code></pre>
  
  <p>It works well, background is black.
  But once I added background attribute to xml, setBackgroundResource
  not work anymore(layout_test.xml):</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/white"/&gt;
  </code></pre>
  
  <p>activity_layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  &lt;TestView
          android:id="@+id/testView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><a href="https://github.com/MummyDing/TestView" rel="nofollow noreferrer">github.com/MummyDing/TestView</a> </p>