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>