關於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