英文:
Render Problems with TabLayout and ViewHolder
问题
I am currently unable to render an activity with just a TabLayout and ViewPager. I am getting this error:
Style ResourceReference{namespace=apk/res-auto, type=attr, name=textAppearanceButton} is not of type STYLE (instead attr)
From the following code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    tools:context=".CompoundInterest">
    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="409dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="86dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabAbout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="About" />
        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabCalculator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Calculator" />
    </com.google.android.material.tabs.TabLayout>
    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tabLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>
I added the TabLayout and ViewPager to an otherwise blank, new layout and they have never rendered, even after being 'connected' to the fragments.
英文:
I am currently unable to render am activity with just a TabLayout and ViewPager. I am getting this error:
Style ResourceReference{namespace=apk/res-auto, type=attr, name=textAppearanceButton} is not of type STYLE (instead attr)
From the following code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    tools:context=".CompoundInterest">
    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="409dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="86dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabAbout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="About" />
        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabCalculator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Calculator" />
    </com.google.android.material.tabs.TabLayout>
    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tabLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>
I added the TabLayout and ViewPager to an otherwise blank, new layout and they have never rendered, even after being 'connected' to the fragments.
答案1
得分: 9
前往Android视图,找到Gradle Scripts - build.gradle(Module: App),然后进行编辑。
将
implementation 'com.google.android.material:material:1.9.0'
更改为
implementation 'com.google.android.material:material:1.7.0'
最后,点击与Gradle文件同步项目,等待一分钟,就可以了。
英文:
Go to the Android View, find the Gradle Scripts - build.gralde(Module :App) then edit it.
change
implementation 'com.google.android.material:material:1.9.0'
to
implementation 'com.google.android.material:material:1.7.0'
Finally, click Sync Project with Gradle Files, wait a minute, it would be fine.
答案2
得分: 4
有关版本1.8.0似乎存在问题。
其他Material Design示例
TabLayout中的TabItems也存在渲染问题。
降级到1.7.0可以正常工作。
英文:
There seems to be a problem with version 1.8.0.
Other Material Design examples
TabItems in TabLaout are also having rendering issues.
Downgrading to 1.7.0 works fine.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论