2017-02-20 16 views
5

Tôi muốn chỉ làm cho chỉ báo Tab roundcorner không phải toàn bộ tab. Tôi đã thử đặt chế độ xem tùy chỉnh nhưng nó không giúp tôi. Bất kỳ trợ giúp sẽ được đánh giá cao. Cảm ơnTùy chỉnh chỉ báo TabLayout. Làm chỉ báo Tab Góc tròn?

+0

Kiểm tra xem nó có hoạt động http://stackoverflow.com/a/34432781/5996106 –

+0

@KarandeepAtwal Nó không hoạt động –

+0

Bạn có tìm thấy giải pháp nào không? – Anu

Trả lời

0

Bạn có thể sử dụng thư viện này CircularIndicatorTabLayout.

Lắp đặt

  • Bạn có thể tải tập tin aar của thư viện từ here
  • Move tròn-idicator-tab-layout-1.0.0.aar để app/libs
  • Trong tệp build.gradle của dự án, hãy thêm kho lưu trữ { flatDir { dirs 'libs' } }
  • Trong ứng dụng b uild.gradle tập tin thêm compile(name: 'circular-idicator-tab-layout-1.0.0', ext: 'aar')

Ví dụ

  • Trong file layout của bạn thêm

    <np.com.ngimasherpa.citablayout.CircularIndicatorTabLayout 
        android:id="@+id/tab_monitoring_criteria" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/spacing_72" 
        app:iconColor="@color/colorPrimaryDark" 
        app:indicatorColor="@color/colorAccent" 
        app:indicatorPosition="bottom" 
        app:lineColor="@android:color/holo_red_dark" 
        app:lineEnabled="true" 
        app:mode="fixed" 
        app:selectedIconColor="@color/colorAccent" 
        app:tabViewIconId="@+id/iconTabViewLayout" 
        app:tabViewLayoutId="@layout/tab_layout" 
        app:tabViewTextViewColor="@color/colorPrimaryDark" 
        app:tabViewTextViewId="@+id/textTabViewLayout" 
        app:tabViewTextViewSelectedColor="@color/colorAccent" 
        app:tab_gravity="fill" /> 
    
  • Trong file java của bạn

    SectionPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); 
    ViewPager mViewPager = (ViewPager) findViewById(R.id.container); 
    CircularIndicatorTabLayout tabLayout = (CircularIndicatorTabLayout) findViewById(R.id.tab_monitoring_criteria); 
    mViewPager.setAdapter(mSectionsPagerAdapter); 
    tabLayout.setupWithViewPager(mViewPager); 
    tabLayout.setIcons(R.drawable.ic_arrow_drop_down, R.drawable.ic_audiotrack, R.drawable.ic_beach); 
    
Các vấn đề liên quan