搜索
热搜: 活动 交友 discuz
查看: 3581|回复: 0
打印 上一主题 下一主题

自定义滑动指示器+ViewPager

[复制链接]

160

主题

165

帖子

814

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
814
跳转到指定楼层
楼主
发表于 2017-2-11 10:47:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1:XML布局
  1.     <com.hh85.zhenxinggan.view.IndicatorViewPager
  2.         android:id="@+id/indicator"
  3.         android:layout_height="45dp"
  4.         android:layout_width="match_parent"
  5.         android:background="@color/header_text"

  6.         fn:show_tab_count="2"


  7.         />
  8.     <android.support.v4.view.ViewPager
  9.         android:id="@+id/viewpage"
  10.         android:layout_width="fill_parent"
  11.         android:layout_height="0dp"
  12.         android:layout_weight="1"
  13.         />
复制代码
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>

  3.     <declare-styleable name="IndicatorViewPager">
  4.         <attr name="show_tab_count" format="integer"/>
  5.         <attr name="normal_color" format="string"/>
  6.         <attr name="highlight_color" format="string"/>
  7.     </declare-styleable>

  8. </resources>
复制代码



2:java代码



  1. indicatorAdapter = new IndicatorAdapter(getSupportFragmentManager(),fragments);
  2.         viewPager = (ViewPager) findViewById(R.id.viewpage);
  3.         viewPager.setAdapter(indicatorAdapter);



  4.         indicator = (IndicatorViewPager) findViewById(R.id.indicator);

  5.         indicator.setTabItems(new String[]{"最新","同城","热门"});
  6.         indicator.setViewPager(viewPager,0);
复制代码





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|安卓论坛  

GMT+8, 2024-4-29 19:43 , Processed in 0.070311 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2013 Design S!|ƽ̶

快速回复 返回顶部 返回列表