title: Losing styles when inheriting from Material Card View Group
body: <p>I'm writing a coursework project and I need to create a custom material card.
  But when I inherit a material card, the styles disappear. I have tried all the solutions I found on the Internet. I will be grateful for any help.</p>
  <p>MainActivity.java</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Case aCase = new Case();
      aCase.setId(183928);
      aCase.setStatus(&quot;Status&quot;);
      aCase.setDescription(&quot;fermentum dui faucibus in ornare quam viverra orci sagittis eu&quot;);
  
      CaseView caseView = findViewById(R.id.caseView);
      caseView.setCase(aCase);
  }
  }
  </code></pre>
  <p>activity_main.xml</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;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
  &lt;com.google.android.material.card.MaterialCardView
      android:id=&quot;@+id/card&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_margin=&quot;8dp&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;vertical&quot;&gt;
  
          &lt;LinearLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;
              android:padding=&quot;16dp&quot;&gt;
  
              &lt;TextView
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot;@string/title&quot;
                  android:textAppearance=&quot;?attr/textAppearanceHeadline6&quot; /&gt;
  
              &lt;TextView
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;8dp&quot;
                  android:text=&quot;secondary_text&quot;
                  android:textAppearance=&quot;?attr/textAppearanceBody2&quot;
                  android:textColor=&quot;?android:attr/textColorSecondary&quot; /&gt;
  
              &lt;TextView
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;16dp&quot;
                  android:text=&quot;supporting_text&quot;
                  android:textAppearance=&quot;?attr/textAppearanceBody2&quot;
                  android:textColor=&quot;?android:attr/textColorSecondary&quot; /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_margin=&quot;8dp&quot;
              android:orientation=&quot;horizontal&quot;&gt;
  
              &lt;com.google.android.material.button.MaterialButton
                  style=&quot;?attr/borderlessButtonStyle&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginEnd=&quot;8dp&quot;
                  android:text=&quot;action_1&quot; /&gt;
  
              &lt;com.google.android.material.button.MaterialButton
                  style=&quot;?attr/borderlessButtonStyle&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot;action_2&quot; /&gt;
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/com.google.android.material.card.MaterialCardView&gt;
  
  &lt;com.barmatograf.interpolith.view.CaseView
      android:id=&quot;@+id/caseView&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>screenshot <a href="https://i.stack.imgur.com/htRq0.png" rel="nofollow noreferrer">https://i.stack.imgur.com/htRq0.png</a></p>
  <p>model class for custom card</p>
  <pre><code>package com.barmatograf.interpolith.model;
  
  public class Case {
      private Integer id;
      private String description;
      private String status;
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  }
  </code></pre>
  <p>CaseView.java</p>
  <pre><code>package com.barmatograf.interpolith.view;
  
  import android.content.Context;
  import android.util.AttributeSet;
  import android.widget.TextView;
  
  import com.barmatograf.interpolith.R;
  import com.barmatograf.interpolith.model.Case;
  import com.google.android.material.card.MaterialCardView;
  
  public class CaseView extends MaterialCardView {
  private Case aCase;
  private TextView number;
  private TextView status;
  private TextView description;
  
  public CaseView(Context context) {
      this(context, null);
  }
  
  public CaseView(Context context, AttributeSet attrs) {
      this(context, attrs, R.attr.materialCardViewStyle);
  }
  
  public CaseView(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      init(context);
  }
  
  private void init(Context context) {
      inflate(context, R.layout.case_view_layout, this);
      number = findViewById(R.id.case_number);
      status = findViewById(R.id.case_status);
      description = findViewById(R.id.case_description);
  }
  
  public void setCase(Case aCase) {
      this.aCase = aCase;
      if (aCase != null) {
          if (aCase.getId() != null)
              number.setText(String.valueOf(aCase.getId()));
          if (aCase.getStatus() != null)
              status.setText(aCase.getStatus());
          if (aCase.getDescription() != null) {
              String descriptionText = aCase.getDescription();
              int length = Math.min(descriptionText.length(), 100);
              descriptionText = descriptionText.substring(0, length);
              descriptionText = descriptionText.trim();
              descriptionText = descriptionText + &quot;...&quot;;
              description.setText(descriptionText);
          }
      }
  }
  
  public Case getCase() {
      return aCase;
  }
  }
  </code></pre>
  <p>case_view_layout.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;com.google.android.material.card.MaterialCardView 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;
      android:layout_margin=&quot;8dp&quot;
      android:orientation=&quot;horizontal&quot;&gt;
  
  &lt;LinearLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:padding=&quot;16dp&quot;&gt;
  
          &lt;TextView
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;@string/title&quot;
              android:textAppearance=&quot;?attr/textAppearanceHeadline6&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/case_number&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textAppearance=&quot;?attr/textAppearanceHeadline6&quot; /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;TextView
          android:id=&quot;@+id/case_status&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;8dp&quot;
          android:textAppearance=&quot;?attr/textAppearanceBody2&quot;
          android:textColor=&quot;?android:attr/textColorSecondary&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/case_description&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;16dp&quot;
          android:textAppearance=&quot;?attr/textAppearanceBody2&quot;
          android:textColor=&quot;?android:attr/textColorSecondary&quot; /&gt;
  &lt;/LinearLayout&gt;
  &lt;/com.google.android.material.card.MaterialCardView&gt;
  </code></pre>
  <p>styles</p>
  <pre><code>&lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.MaterialComponents&quot;&gt;
      &lt;item name=&quot;materialCardViewStyle&quot;&gt;@style/Widget.MaterialComponents.CardView&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>