底部状态栏(JPTabBar)

 

JPTabBar

依赖

//JPTabBar
implementation 'com.jpeng:JPTabBar:1.2.3'

//BottomNavigationBar
  implementation 'com.ashokvarma.android:bottom-navigation-bar:2.0.4'

Xml 

<android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_weight="9"
        android:layout_width="match_parent"
        android:layout_height="0dp"></android.support.v4.view.ViewPager>

<com.jpeng.jptabbar.JPTabBar
        android:id="@+id/jptab"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"></com.jpeng.jptabbar.JPTabBar>

代码

//  
@Titles
    private static final String [] mTitles={"故事","亲自"};

//不点击时的图片
    @NorIcons
    private static final int [] mNorIcons={R.drawable.tabbar_icon_story_n,R.drawable.tabbar_icon_lis_n};
//点击时的图片
    @SeleIcons
    private static final int [] mSeleIcons={R.drawable.tabbar_icon_story_s,R.drawable.tabbar_icon_lis_s};

//OnCreate里写的

 fragments=new ArrayList<>();
        try {
            fragments.add(StoryFragment.class.newInstance());
            fragments.add(QZFragment.class.newInstance());
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        jptab.setContainer(pager);
        adapter=new PagerFragmentAdapter(getSupportFragmentManager(),fragments);
        pager.setAdapter(adapter);

猜你喜欢

转载自blog.csdn.net/weixin_42421241/article/details/81086421