关于android.support.design.widget.TabLayout无法使用


Android Studio3.5,可能是新版本Android,无法使用android.support.design.widget.TabLayout,因此选择com.google.android.material.tabs.TabLayout。

如果是xml文件中报错,首先注意MainActivity中引入的是哪个tablayout包,我发现自己引入的是Google的,因此在xml中也使用了Google的tablayout,解决了错误。

配置文件中引入:

implementation 'com.android.support:support-v4:29.0.2'
implementation 'com.android.support:design:29.0.2'

activity_main.xml中部分代码

<com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="#ffffff"
        app:tabIndicatorColor="@color/design_default_color_primary"
        app:tabIndicatorHeight="8dp"

        app:tabSelectedTextColor="#000000"
        app:tabMode="fixed"
        app:tabBackground="@drawable/selected"
        />

其余使用与android.support.design.widget.TabLayout相同





免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM