UI框架之SmartTabLayout使用

 项目git地址:https://github.com/lantian0314/ndkDemo

SmartTabLayout实现viewpgaer页面导航效果,简化并实现android的TabHost效果,顶部滑动tab,引导页,可以自定义tab样式,过渡效果 实现网易tab,微博tab,微信tab等so easy。 集成了SpringIndicator拖拽效果 

UI框架之SmartTabLayout使用_第1张图片

开源项目的git地址:https://github.com/ogaclejapan/SmartTabLayout

第一、配置build.gradle文件

compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
    //Optional: see how to use the utility.

compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'

第二、Layout界面布局

2.1 samrttable布局



    

    

2.1 smart_fragment.xml 布局



    

第三、Activity

public class SmartTable extends AppCompatActivity {
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    @BindView(R.id.viewpagertab)
    SmartTabLayout smartTabLayout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.smarttable);
        ButterKnife.bind(this);
        FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
                getSupportFragmentManager(), FragmentPagerItems.with(this)
                .add(R.string.message, SmartFragment.class)
                .add(R.string.dynamic, SmartFragment.class)
                .add(R.string.contact, SmartFragment.class)
                .add(R.string.message, SmartFragment.class)
                .add(R.string.dynamic, SmartFragment.class)
                .add(R.string.contact,SmartFragment.class)
                .create());

        viewPager.setAdapter(adapter);
        smartTabLayout.setViewPager(viewPager);
    }
public class SmartFragment extends Fragment {
    TextView txt_itemtitle;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.smart_fragment, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        int position = FragmentPagerItem.getPosition(getArguments());
        txt_itemtitle = (TextView) view.findViewById(R.id.txt_itemtitle);
        txt_itemtitle.setText(String.valueOf(position));
    }
}

你可能感兴趣的:(Android,AndroidStudio,UI框架)