title: Android Nougat: TextureView doesn't support displaying a background drawable
body: <p>I have been using a TextureView in my android app, and it was working fine. Just recently I tested my code on an Android device with Android API 25 (7.1.2). Same code now does not work and throws the error, <code>java.lang.UnsupportedOperationException: TextureView doesn't support displaying a background drawable</code>.</p>
  
  <p>I know that <code>void setBackgroundDrawable (Drawable background)</code> had been <a href="https://developer.android.com/reference/android/view/TextureView.html" rel="noreferrer">deprecated for a long time</a>, and now it must have been removed. But I am not even setting it by myself.</p>
  
  <p>I am using latest buildTools and SDK. So, <strong>I wonder why hasn't the textureView internal implementation been updated.</strong></p>
  
  <p><strong>Here is the relevant stack trace:</strong></p>
  
  <pre><code>java.lang.UnsupportedOperationException: TextureView doesn't support displaying a background drawable
  at android.view.TextureView.setBackgroundDrawable(TextureView.java:315)
  at android.view.View.setBackground(View.java:18124)
  at android.view.View.&lt;init&gt;(View.java:4573)
  at android.view.View.&lt;init&gt;(View.java:4082)
  at android.view.TextureView.&lt;init&gt;(TextureView.java:159)
  at com.abdulwasaetariq.xyz.ui.customView.AutoFitTextureView.&lt;init&gt;(AutoFitTextureView.java:24)
  at com.abdulwasaetariq.xyz.ui.customView.AutoFitTextureView.&lt;init&gt;(AutoFitTextureView.java:20)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  [...]
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p><strong>Here is how i use my (not-yet customized) custom TextureView:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.abdulwasaetariq.xyz.ui.activity.MainActivity"&gt;
  
      &lt;com.abdulwasaetariq.xyz.ui.customView.AutoFitTextureView
          android:id="@+id/texture"
          android:layout_width="1080px"
          android:layout_height="1080px"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Here is my relevant AutoFitTextureView.java:</strong> <code>enter code here</code></p>
  
  <pre><code>public class AutoFitTextureView extends TextureView {
  
  private int mRatioWidth = 0;
  private int mRatioHeight = 0;
  
  public AutoFitTextureView(Context context) {
      this(context, null);
  }
  
  public AutoFitTextureView(Context context, AttributeSet attrs) {
      this(context, attrs, 0); //(LINE#20)
  }
  
  public AutoFitTextureView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle); //(LINE#24)
  }
  
  public void setAspectRatio(int width, int height) {
      if (width &lt; 0 || height &lt; 0) {
          throw new IllegalArgumentException("Size cannot be negative.");
      }
      mRatioWidth = width;
      mRatioHeight = height;
      requestLayout();
  }
  
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      int width = MeasureSpec.getSize(widthMeasureSpec);
      int height = MeasureSpec.getSize(heightMeasureSpec);
      if (0 == mRatioWidth || 0 == mRatioHeight) {
          setMeasuredDimension(width, height);
      } else {
          if (width &lt; height * mRatioWidth / mRatioHeight) {
              setMeasuredDimension(width, width * mRatioHeight / mRatioWidth);
          } else {
              setMeasuredDimension(height * mRatioWidth / mRatioHeight, height);
          }
      }
  }}
  </code></pre>
  
  <p>So, as you can see, the exceptions occur at the <code>super()</code> methods, which means that my custom TextureView is not responsible for this exception. It's an inside call.</p>
  
  <p>Here is my gradle config:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 25
      buildToolsVersion '25.0.2'
      defaultConfig {
          applicationId "com.abdulwasaetariq.xyz"
          minSdkVersion 21
          targetSdkVersion 25
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
          })
      compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
      compile 'com.github.hotchemi:permissionsdispatcher:2.3.2'
      annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.2'
  }
  </code></pre>
  
  <p><strong>Any ideas why this may be happening? Any release-notes of Android API 25, where this change is talked about?</strong></p>