Status Update
Comments
am...@google.com <am...@google.com>
ra...@gmail.com <ra...@gmail.com> #3
I have also faced the same issue. When I click or swipe the tabs, the underline and the tab text highlight move correctly. However, then I programmatically call mViewPager.setCurrentItem(position); the underline moves correctly, but the tab text highlight does not move to the new tab. It was working fine on the previous version.
am...@google.com <am...@google.com> #4
Hi ,
Please share the sample code to reproduce the issue.
share the code and screenshot of observed and expected output to google drive and share the folder to android-bugreport@google.com, then share the link here.
Please share the sample code to reproduce the issue.
share the code and screenshot of observed and expected output to google drive and share the folder to android-bugreport@google.com, then share the link here.
ra...@gmail.com <ra...@gmail.com> #5
Hi,
Below is the screenshot link on google drive:
https://drive.google.com/file/d/0B1GBHpKXRso-dW9iQXpRREdNaFE/view?usp=sharing
As you can see the orange underline is under PORTFOLIO, but the bold title is WATCHLIST. This shouldn't be possible in any situation, but it specifically happens when .setcurrentitem is called. Regular swiping and clicking on tabs work as expected and the bold and underline are on the same tab
Code is simple, since I am using navigation drawer, I have to programmatically change the current tab. I have also tried the viewpager.setcurrentitem in another situation and it has the same issue. This did not happen before 23.1.0. Currently , I am using 23.1.1 but the issue is still there.
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
//menuItem.setChecked(true);
switch (menuItem.getItemId()) {
case R.id.menuItem0:
myViewPager.setCurrentItem(0);
break;
case R.id.menuItem1:
myViewPager.setCurrentItem(1);
break;
case R.id.menuItem2:
myViewPager.setCurrentItem(2);
break;
case R.id.menuItem3:
myViewPager.setCurrentItem(3);
break;
case R.id.menuItem4:
myViewPager.setCurrentItem(4);
break;
Below is the screenshot link on google drive:
As you can see the orange underline is under PORTFOLIO, but the bold title is WATCHLIST. This shouldn't be possible in any situation, but it specifically happens when .setcurrentitem is called. Regular swiping and clicking on tabs work as expected and the bold and underline are on the same tab
Code is simple, since I am using navigation drawer, I have to programmatically change the current tab. I have also tried the viewpager.setcurrentitem in another situation and it has the same issue. This did not happen before 23.1.0. Currently , I am using 23.1.1 but the issue is still there.
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
//menuItem.setChecked(true);
switch (menuItem.getItemId()) {
case R.id.menuItem0:
myViewPager.setCurrentItem(0);
break;
case R.id.menuItem1:
myViewPager.setCurrentItem(1);
break;
case R.id.menuItem2:
myViewPager.setCurrentItem(2);
break;
case R.id.menuItem3:
myViewPager.setCurrentItem(3);
break;
case R.id.menuItem4:
myViewPager.setCurrentItem(4);
break;
jo...@gmail.com <jo...@gmail.com> #6
The problem might be in the TabLayouts internal ViewPager.OnPageChangeListener
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
final TabLayout tabLayout = mTabLayoutRef.get();
if (tabLayout != null) {
// Update the scroll position, only update the text selection if we're being
// dragged (or we're settling after a drag)
final boolean updateText = (mScrollState == ViewPager.SCROLL_STATE_DRAGGING)
|| (mScrollState == ViewPager.SCROLL_STATE_SETTLING
&& mPreviousScrollState == ViewPager.SCROLL_STATE_DRAGGING);
tabLayout.setScrollPosition(position, positionOffset, updateText);
}
}
At this point
mScrollState == ViewPager.SCROLL_STATE_SETTLING
mPreviousScrollState != ViewPager.SCROLL_STATE_DRAGGING
-> updateText == false!
I guess the reason is because we didnt make a DRAG, but instead changed the page programatically.
The problem could also be this commit:https://github.com/android/platform_frameworks_support/commit/854d6b89f46fb2877c009eaa80394b8c8079f7ee
Before that commit the tab would have updated in public void onPageSelected(int position) regardless if the mScrollState is IDLE or SETTLING (it's settling at this point)
@Override
public void onPageSelected(int position) {
final TabLayout tabLayout = mTabLayoutRef.get();
if (tabLayout != null && tabLayout.getSelectedTabPosition() != position) {
// Select the tab, only updating the indicator if we're not being dragged/settled
// (since onPageScrolled will handle that).
tabLayout.selectTab(tabLayout.getTabAt(position),
mScrollState == ViewPager.SCROLL_STATE_IDLE);
}
}
A temporary workaround would be to manually call tabLayout.setScrollPosition(pos, 0, true) just after the call to setCurrentItem(pos)
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
final TabLayout tabLayout = mTabLayoutRef.get();
if (tabLayout != null) {
// Update the scroll position, only update the text selection if we're being
// dragged (or we're settling after a drag)
final boolean updateText = (mScrollState == ViewPager.SCROLL_STATE_DRAGGING)
|| (mScrollState == ViewPager.SCROLL_STATE_SETTLING
&& mPreviousScrollState == ViewPager.SCROLL_STATE_DRAGGING);
tabLayout.setScrollPosition(position, positionOffset, updateText);
}
}
At this point
mScrollState == ViewPager.SCROLL_STATE_SETTLING
mPreviousScrollState != ViewPager.SCROLL_STATE_DRAGGING
-> updateText == false!
I guess the reason is because we didnt make a DRAG, but instead changed the page programatically.
The problem could also be this commit:
Before that commit the tab would have updated in public void onPageSelected(int position) regardless if the mScrollState is IDLE or SETTLING (it's settling at this point)
@Override
public void onPageSelected(int position) {
final TabLayout tabLayout = mTabLayoutRef.get();
if (tabLayout != null && tabLayout.getSelectedTabPosition() != position) {
// Select the tab, only updating the indicator if we're not being dragged/settled
// (since onPageScrolled will handle that).
tabLayout.selectTab(tabLayout.getTabAt(position),
mScrollState == ViewPager.SCROLL_STATE_IDLE);
}
}
A temporary workaround would be to manually call tabLayout.setScrollPosition(pos, 0, true) just after the call to setCurrentItem(pos)
am...@google.com <am...@google.com> #7
Hi, please do attach the sample project which reproduces the issue.
am...@google.com <am...@google.com> #8
Hi, please do attach the sample project which reproduces the issue.
jo...@gmail.com <jo...@gmail.com> #10
Click the FAB to programmatically change to the second tab.
am...@google.com <am...@google.com> #11
Please don't share this way. it's difficult to the grab the contents from the bits and pieces shared here. somehow, Took the contents , but getting some exception, so please put all these into zip and share the link of the zip.
jo...@gmail.com <jo...@gmail.com> #12
Hah. Sorry about that. I misunderstood your previous instruction. I thought it was a bit weird that I should share the project like that.
Anyhow, here's a link to a zip of the project:https://drive.google.com/open?id=0B1rITGUSY9mcTGFEUWhlYVpLMDQ
Anyhow, here's a link to a zip of the project:
am...@google.com <am...@google.com> #13
Hi,
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
[Deleted User] <[Deleted User]> #14
i have same issue 36903771 .1.1 version
please fix
please fix
am...@google.com <am...@google.com> #15
Hi,
The development team has fixed the issue that you have reported and it will be available in a future build
Thanks
The development team has fixed the issue that you have reported and it will be available in a future build
Thanks
ra...@gmail.com <ra...@gmail.com> #17
Hi, It has been November 2015 since amruthav reported that it has been fixed. When will be getting the future build in which it has been fixed?
ra...@gmail.com <ra...@gmail.com> #19
I can confirm that this has been fixed in version 23.2.0
am...@google.com <am...@google.com> #20
Hi,
As it is fixed in latest release, closing it. In case if you are able to reproduce the issue, please let us know by raining new issue
Thanks
As it is fixed in latest release, closing it. In case if you are able to reproduce the issue, please let us know by raining new issue
Thanks
mu...@gmail.com <mu...@gmail.com> #21
I was able to reproduce this issue again on `23.4.0`
mt...@gmail.com <mt...@gmail.com> #22
I was able to reproduce this issue again on `25.3.1`
Description
* When I scroll between two tabs in a TabLayout, the tab text highlights correctly.
* When I tap on a tab in the TabLayout, the tab text also highlights correctly.
* If I programmatically call mViewPager.setCurrentItem(), the tab text does NOT highlight. I would expect it to do so.
This seems to be a regression, as my code worked fine with the 22.2.1 design library, but is now broken.
As a workaround, I have found if I replace:
mViewPager.setCurrentItem(position);
with:
mTabLayout.getTabAt(position).select();
then it seems to work - the tab is selected AND the tab text is highlighted.