Android CV系列 > 导航栏 能滑的 不能滑的 带图的 不带图的

1.https://github.com/yaochangliang159/Android-TabView

compile 'com.ycl.tabview.library:tabviewlibrary:1.0'
 <com.ycl.tabview.library.TabView
        app:tab_tabViewDefaultPosition="2"
        app:tab_textViewSelColor="#f00"
        app:tab_textViewUnSelColor="#ff0"
        android:id="@+id/tabView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
  List<TabViewChild> tabViewChildList=new ArrayList<>();
        TabViewChild tabViewChild01=new TabViewChild(R.drawable.vip_card_1,R.mipmap.ic_launcher,"首页",  new BlankFragment());
        TabViewChild tabViewChild02=new TabViewChild(R.drawable.vip_card_2,R.mipmap.ic_launcher,"分类",  new BlankFragment2());
        TabViewChild tabViewChild03=new TabViewChild(R.drawable.vip_card_3,R.mipmap.ic_launcher,"资讯",  new BlankFragment3());
        TabViewChild tabViewChild04=new TabViewChild(R.drawable.vip_card_4,R.mipmap.ic_launcher,"购物车",new BlankFragment4());
        TabViewChild tabViewChild05=new TabViewChild(R.drawable.vip_card_5,R.mipmap.ic_launcher,"我的",  new BlankFragment5());
        tabViewChildList.add(tabViewChild01);
        tabViewChildList.add(tabViewChild02);
        tabViewChildList.add(tabViewChild03);
        tabViewChildList.add(tabViewChild04);
        tabViewChildList.add(tabViewChild05);
        tabView.setTabViewChild(tabViewChildList,getSupportFragmentManager());
        tabView.setSelected(true);

最主要的是它可以上下左右四个方向摆放,可惜不能滑动

2.防微信 CV自https://github.com/nyakokishi/WeChatRadioBar

MainAc

public class MainActivity extends AppCompatActivity {
    private ViewPager viewPager;
    private WeChatRadioGroup gradualRadioGroup;
    private WeChatRadioButton animate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        viewPager = (ViewPager) findViewById(R.id.viewpager);
        gradualRadioGroup = (WeChatRadioGroup) findViewById(R.id.radiogroup);
        List<DemoFragment> list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            DemoFragment fragment = new DemoFragment();
            list.add(fragment);
        }
        viewPager.setAdapter(new DemoPagerAdapter(getSupportFragmentManager(), list));
        gradualRadioGroup.setViewPager(viewPager);
        gradualRadioGroup.clearAnimation();
    }

    private void initView() {

    }

    class DemoPagerAdapter extends FragmentPagerAdapter {
        List<DemoFragment> mData;

        public DemoPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        public DemoPagerAdapter(FragmentManager fm, List<DemoFragment> data) {
            super(fm);
            mData = data;
        }

        @Override
        public Fragment getItem(int position) {
            return mData.get(position);
        }

        @Override
        public int getCount() {
            return mData.size();
        }
    }
}

XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <io.github.leibnik.wechatradiobar.WeChatRadioGroup xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/radiogroup"
        android:layout_width="match_parent"
        android:layout_height="53dp"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        >

        <io.github.leibnik.wechatradiobar.WeChatRadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:checked="true"
            android:gravity="center"
            android:paddingTop="3dp"
            android:text="微信"
            android:textColor="#555"
            android:textSize="13sp"
            app:defocus_icon="@drawable/chats"
            app:focus_color="#50ba26"
            app:focus_icon="@drawable/chats_green"
            />

        <io.github.leibnik.wechatradiobar.WeChatRadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:paddingTop="3dp"
            android:text="通讯录"
            android:textColor="#555"
            android:textSize="13sp"
            app:defocus_icon="@drawable/contacts"
            app:focus_color="#50ba26"
            app:focus_icon="@drawable/contacts_green"
            />

        <io.github.leibnik.wechatradiobar.WeChatRadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:paddingTop="3dp"
            android:text="发现"
            android:textColor="#555"
            android:textSize="13sp"
            app:defocus_icon="@drawable/discover"
            app:focus_color="#50ba26"
            app:focus_icon="@drawable/discover_green"
            />

        <io.github.leibnik.wechatradiobar.WeChatRadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:paddingTop="3dp"
            android:text="我"
            android:textColor="#555"
            android:textSize="13sp"
            app:defocus_icon="@drawable/about_me"
            app:focus_color="#50ba26"
            app:focus_icon="@drawable/about_me_green"
            />
    </io.github.leibnik.wechatradiobar.WeChatRadioGroup>

    <View
        android:id="@+id/line"
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:layout_above="@id/radiogroup"
        android:background="#555"
        />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/line"
        />
</RelativeLayout>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值