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相同
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。