当前位置: 首页>>代码示例>>Java>>正文


Java TabLayout.setTabGravity方法代码示例

本文整理汇总了Java中android.support.design.widget.TabLayout.setTabGravity方法的典型用法代码示例。如果您正苦于以下问题:Java TabLayout.setTabGravity方法的具体用法?Java TabLayout.setTabGravity怎么用?Java TabLayout.setTabGravity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.TabLayout的用法示例。


在下文中一共展示了TabLayout.setTabGravity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.activity_dual_tab_photos, container, false);
    ((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar));

    TabLayout tabLayout = root.findViewById(R.id.tablayout);
    tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
    int tabColorPrimary = CurrentTheme.getPrimaryTextColorOnColoredBackgroundCode(getActivity());
    int tabColorSecondary = CurrentTheme.getSecondaryTextColorOnColoredBackgroundCode(getActivity());
    tabLayout.setTabTextColors(tabColorSecondary, tabColorPrimary);

    ViewPager viewPager = root.findViewById(R.id.view_pager);
    viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
        @Override
        public void onPageSelected(int position) {
            mCurrentTab = position;
        }
    });

    mPagerAdapter = new Adapter(getChildFragmentManager(), mSources);
    viewPager.setAdapter(mPagerAdapter);

    tabLayout.setupWithViewPager(viewPager, true);
    return root;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:27,代码来源:DualTabPhotosFragment.java

示例2: onViewCreated

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    ViewPager viewPager = view.findViewById(R.id.viewpager);
    viewPager.setOffscreenPageLimit(1);
    setupViewPager(viewPager);

    TabLayout tabLayout = view.findViewById(R.id.tablayout);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);

    int tabColorPrimary = CurrentTheme.getPrimaryTextColorOnColoredBackgroundCode(getActivity());
    int tabColorSecondary = CurrentTheme.getSecondaryTextColorOnColoredBackgroundCode(getActivity());
    tabLayout.setTabTextColors(tabColorSecondary, tabColorPrimary);
    tabLayout.setupWithViewPager(viewPager);

    if(getArguments().containsKey(Extra.TAB)){
        int tab = getArguments().getInt(Extra.TAB);
        getArguments().remove(Extra.TAB);
        viewPager.setCurrentItem(tab);
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:22,代码来源:FaveTabsFragment.java

示例3: setTabLayout

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@NonNull
private TabLayout setTabLayout(View view) {
    TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout_rewards);

    tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.available_rewards_tab)));
    tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.exchanged_rewards_tab)));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    Typeface typeface = Typeface.createFromAsset(getContext().getAssets(),
            "fonts/Nunito-Regular.ttf");
    ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);

    for (int i = 0; i < 2; i++) {
        AppCompatTextView appCompatTextView = (AppCompatTextView) ((ViewGroup) viewGroup
                .getChildAt(i)).getChildAt(1);
        appCompatTextView.setTypeface(typeface, Typeface.NORMAL);
    }
    return tabLayout;
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:20,代码来源:AwardsFragment.java

示例4: onCreateView

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.content_notifications, container, false);

    AppBarLayout appBarLayout = getActivity().findViewById(R.id.appbar);

    if (appBarLayout.getChildCount() == 1) {
        mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());

        mViewPager = rootView.findViewById(R.id.tab_container);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        mTabLayout = new TabLayout(getActivity());
        mTabLayout.setTabTextColors(
                getResources().getColor(R.color.disabledGrey),
                getResources().getColor(R.color.white)
        );
        mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        mTabLayout.setupWithViewPager(mViewPager);

        appBarLayout.addView(mTabLayout);
    }

    return rootView;
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:26,代码来源:NotificationsFragment.java

示例5: init

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void init(){
    addTapData();
    viewPager = (MyViewPager)findViewById(R.id.local_viewPager);
    tabLayout = (TabLayout)findViewById(R.id.local_tab);
    fragmentAdapter = new MyAdapter(getSupportFragmentManager());
    viewPager.setAdapter(fragmentAdapter);
    viewPager.setOffscreenPageLimit(2); //预加载页面数
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setupWithViewPager(viewPager);

    nothingTv = (TextView)findViewById(R.id.local_nothing_tv);
    nothingTv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(LocalMusicActivity.this,ScanActivity.class);
            startActivity(intent);
        }
    });

}
 
开发者ID:lijunyandev,项目名称:MeetMusic,代码行数:22,代码来源:LocalMusicActivity.java

示例6: dynamicSetTabLayoutMode

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
/**
 * 动态修改tab的模式
 *
 * @param tabLayout tabLayout
 */
public static void dynamicSetTabLayoutMode(TabLayout tabLayout) {
    int tabTotalWidth = 0;
    for (int i = 0; i < tabLayout.getChildCount(); i++) {
        final View view = tabLayout.getChildAt(i);
        view.measure(0, 0);
        tabTotalWidth += view.getMeasuredWidth();
    }
    if (tabTotalWidth <= MeasureUtils.getScreenSize(tabLayout.getContext()).x) {
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    } else {
        tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
 
开发者ID:shenhuanet,项目名称:OpenEyesReading-android,代码行数:21,代码来源:SinaPhotoActivity.java

示例7: initTab

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public void initTab(TabLayout tabLayout) {
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
    tabLayout.setSelectedTabIndicatorColor(Color.WHITE);
    tabLayout.setTabTextColors(ColorStateList.valueOf(Color.WHITE));
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:9,代码来源:DoubanMovieMoreReviewViewModel.java

示例8: onViewCreated

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    ViewPager viewPager = view.findViewById(R.id.fragment_videos_pager);
    setupViewPager(viewPager);

    TabLayout tabLayout = view.findViewById(R.id.fragment_videos_tabs);
    tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
    int tabColorPrimary = CurrentTheme.getPrimaryTextColorOnColoredBackgroundCode(getActivity());
    int tabColorSecondary = CurrentTheme.getSecondaryTextColorOnColoredBackgroundCode(getActivity());
    tabLayout.setTabTextColors(tabColorSecondary, tabColorPrimary);
    tabLayout.setupWithViewPager(viewPager);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:13,代码来源:VideosTabsFragment.java


注:本文中的android.support.design.widget.TabLayout.setTabGravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。