當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。