Skip to content

Instantly share code, notes, and snippets.

@luQman704
Last active February 4, 2019 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luQman704/fe1c3a96f1a4cefd4935901b63c4956c to your computer and use it in GitHub Desktop.
Save luQman704/fe1c3a96f1a4cefd4935901b63c4956c to your computer and use it in GitHub Desktop.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
setupTabIcons();
LinearLayout layout = ((LinearLayout) ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0));
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) layout.getLayoutParams();
layoutParams.weight = 0f; // e.g. 0.5f
layoutParams.width=LinearLayout.LayoutParams.WRAP_CONTENT;
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new camera(),"");
adapter.addFragment(new converterFragment(), "Convert");
adapter.addFragment(new fileExplorerFragment(), "Files");
viewPager.setAdapter(adapter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment