Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to find '?attr/textAppearanceCaption' in current theme

Tags:

android

Here is my simple xml file

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<FrameLayout
    android:id="@+id/main_screen"
    android:layout_width="match_parent"
    android:layout_height="593dp"
    android:background="@color/CadetBlue"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_menu"
    style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
    android:layout_width="match_parent"
    android:layout_height="67dp"
    android:layout_alignParentBottom="true"
    android:baselineAligned="false"
    app:itemBackground="@color/colorPrimary1"
    app:itemIconTint="@drawable/item_selector"
    app:itemTextColor="@drawable/item_selector"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/main_screen"
    app:menu="@menu/nav_items" />

my build.gradle file is

    //noinspection GradleCompatible
   apply plugin: 'com.android.application'

   android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.smile_sifat.donatethefloody"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
       "android.support.test.runner.AndroidJUnitRunner"
       }
       buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
     'proguard-rules.pro'
        }
    }
  }

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.2'
}

 apply plugin: 'com.google.gms.google-services'
like image 843
Smile Sifat Avatar asked Nov 04 '18 17:11

Smile Sifat


2 Answers

Whenever you use any MaterialComponents style you need to add/define android:textApperance attribute to it.

Add an android:textApperance attribute to your BottomNavigationView relevant to your style to make it work correctly.

like image 134
nitinkumarp Avatar answered Nov 19 '22 06:11

nitinkumarp


In addition to nitinkumarp answer. For example, in the file res/values/styles.xml add:

<style name="TextStyle" parent="@android:style/TextAppearance">
    <item name="android:textSize">20sp</item>
    <item name="android:textColor">#aacbb4</item>
</style>

Then, in the layout file for the component specify the attribute: android:textAppearance="@style/TextStyle"

like image 34
alexrnov Avatar answered Nov 19 '22 06:11

alexrnov