我一直在尝试向活动添加底部导航栏。但是,它说是Failed to find style 'bottomNavigationStyle' in current theme
和The following classes could not be instantiated: - android.support.design.widget.BottomNavigationView
。我在做错什么吗?
我确实在build.gradle文件中实现了该软件包:
implementation 'com.android.support:design:28.0.0-alpha3'
所以,我不认为这是因为...
<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.pineapple.davinci.clubs.Activity_ClubsDashboard"
tools:layout_editor_absoluteY="25dp">
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:visibility="visible"
app:itemIconTint="@drawable/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/navigation" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.pineapple.davinci.clubs.ExpandableHeightGridView
android:id="@+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/clubs"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:columnWidth="160dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:isScrollContainer="false"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="14dp" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="62dp"
android:layout_height="38dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:contentDescription="@drawable/gsmst_logo"
app:srcCompat="@drawable/gsmst_logo" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="20dp"
android:layout_marginTop="37dp"
android:background="@android:color/transparent"
android:contentDescription="@drawable/icon_settings"
app:srcCompat="@drawable/icon_settings" />
<TextView
android:id="@+id/clubs"
android:layout_width="175dp"
android:layout_height="40dp"
android:layout_alignStart="@+id/imageView6"
android:layout_below="@+id/imageView6"
android:text="@string/clubs"
android:textAppearance="@style/header_clubs"
tools:layout_editor_absoluteY="38dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Stackoverflow告诉我编写更多文本,所以我编写更多文本。它仍然希望我添加更多文本...我们去了
答案 0 :(得分:0)
这是支持库中的一个错误,在发布28.0.0
和更高版本中存在很多错误,因此我只将Base.
放在父属性中的主题之前,并且没有给我任何错误。
您要做的就是在您的 styles.xml 文件中将Theme.AppCompat.Light
更改为Base.Theme.AppCompat.Light
。