[英]How to add Badge to Android tablayout
TAB
設計一個custom view
。 TAB
設置custom view
嘗試這個:
// Tab
Tab tab = YourTabLayout.getTabAt(position);
// Get Custom view using LayoutInflater
// ...........
// Set custom view
tab.setCustomView(custom_View);
您將需要向每個選項卡添加自定義View
。 因此,一旦完成ViewPager
和Adapter
設置。
遍歷選項卡並添加自定義視圖。
就像是:
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
tab.setCustomView(createCustomViewForTab(i);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.