title: Why do i get an error when inflating a textview with a custom background?
body: <p>I'm trying to inflate an XML, as an item for RecyclerView, the XML is Constraint Layout with two TextViews
  both TextViews have the same background that I created, it's located in the drawable folder and it's a rectangle shape, in order to create a frame line around the textviews.</p>
  <p>But when I run the app, I get this error:</p>
  <pre><code>Binary XML file line #9: Error inflating class TextView
  </code></pre>
  <p>From reading similar questions, I found out it might happen because of some properties of the textview,  and I found in my case when I remove those backgrounds from the textviews, the inflation works, and everything is fine.</p>
  <p>Can anyone explain why this happens? The XML, the drawable shape, and the error are below:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      &gt;
  
      &lt;TextView
          android:id=&quot;@+id/country_name&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;match_parent&quot;
          android:textSize=&quot;15sp&quot;
          android:text=&quot;@string/countryname&quot;
          android:padding=&quot;4dp&quot;
          app:layout_constraintHorizontal_weight=&quot;50&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toLeftOf=&quot;@id/native_name&quot;
          android:gravity=&quot;center_horizontal&quot;
          android:background=&quot;@drawable/border&quot;
          /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/native_name&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;match_parent&quot;
          android:textSize=&quot;15sp&quot;
          android:text=&quot;@string/nativename&quot;
          android:padding=&quot;4dp&quot;
          app:layout_constraintHorizontal_weight=&quot;50&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintLeft_toRightOf=&quot;@id/country_name&quot;
          android:gravity=&quot;center_horizontal&quot;
          android:background=&quot;@drawable/border&quot;
          /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:shape=&quot;rectangle&quot; &gt;
      &lt;solid android:color=&quot;@android:color/transparent&quot; /&gt;
      &lt;stroke android:width=&quot;1dp&quot; android:color=&quot;#128FD5&quot;/&gt;
  &lt;/shape&gt;
  </code></pre>
  <p>Stack trace:</p>
  <pre><code>Process: com.example.mydemoproj, PID: 7844
      android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class TextView
          at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
          at com.example.mydemoproj.CountriesRecyclerView.RecyclerViewAdaper.onCreateViewHolder(RecyclerViewAdaper.kt:18)
          at com.example.mydemoproj.CountriesRecyclerView.RecyclerViewAdaper.onCreateViewHolder(RecyclerViewAdaper.kt:12)
          at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
          at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
          at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
          at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
          at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
          at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
          at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
          at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
          at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
          at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
          at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
          at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1732)
          at android.widget.LinearLayout.onLayout(LinearLayout.java:1497)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1855)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:530)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
          at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
          at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
          at android.view.View.layout(View.java:16630)
          at android.view.ViewGroup.layout(ViewGroup.java:5437)
          at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
          at android.view.Choreographer.doCallbacks(Choreographer.java:670)
          at android.view.Choreographer.doFrame(Choreographer.java:606)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
          at android.os.Handler.
  </code></pre>