Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Makes using shouldExpand with uneven tabs work correctly #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bartoszfilipowicz
Copy link

With current implementation using shouldExpand="true" with tabs that aren't of the same width may result in cropping longer tab labels.

This is due to setting

new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f)

layout params for every tab whenever the tabs are expanded to fill the whole screen width.

This fix gets weight from the width of the tab:

new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, tabView.getMeasuredWidth())

during the fitting. Thanks to that, the tabs retain their previous proportions.

Current behaviour:

before

After applying this fix:

after

silentnuke-old added a commit to silentnuke-old/PagerSlidingTabStriptest that referenced this pull request Jun 27, 2014
axsddlr added a commit to AOSPA-legacy/android_packages_apps_Settings that referenced this pull request Jul 9, 2014
-- Check if tabCount > 0
(do this before attempting tabsContainer.getChildAt(position) when scrolling to child.)

-- if pager == null no need to call requestLayout()

-- make shouldExpand work correctly
   (referenced here: astuetz/PagerSlidingTabStrip#42)
-- Use Gravity to center tabs

-- add onTabReselected() callbackFunction
  ( referenced here: astuetz/PagerSlidingTabStrip#92)

Change-Id: I0184de3c010a902a721572d3dcaa75101e38aa0c
Signed-off-by: Andre Saddler <dresadd09691@gmail.com>
axsddlr added a commit to AOSPA-legacy/android_packages_apps_Settings that referenced this pull request Jul 9, 2014
-- Check if tabCount > 0
(do this before attempting tabsContainer.getChildAt(position) when scrolling to child.)

-- if pager == null no need to call requestLayout()

-- make shouldExpand work correctly
   (referenced here: astuetz/PagerSlidingTabStrip#42)
-- Use Gravity to center tabs

-- add onTabReselected() callbackFunction
  (referenced here: astuetz/PagerSlidingTabStrip#92)

-- Fix: Tab dislocation caused by setViewPager

Change-Id: I0184de3c010a902a721572d3dcaa75101e38aa0c
Signed-off-by: Andre Saddler <dresadd09691@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant