android-tablayout

How to show unread notification counter on Tabs inside TabLayout?

浪子不回头ぞ 提交于 2019-12-03 15:26:15
I am using TabLayout of android support design library. I want to show unread notification counter on the tab with title like below image. How to set unread count on Tab inside TabLayout ? Use public TabLayout.Tab setCustomView (int layoutResId) Create a Layout with TextView and Button use this in Custom view. For reference setCustomView Example Hope this will helpful to you. Take a look at android-viewbadger ... 来源: https://stackoverflow.com/questions/32269517/how-to-show-unread-notification-counter-on-tabs-inside-tablayout

TabLayout scrolls to unkown position after calling notifyDataSetChanged on PagerAdapter

末鹿安然 提交于 2019-12-03 14:42:13
I have sample project with TabLayout and PagerAdapter . Strange things happens with TabLayout when I call pagerAdapter.notifyDataSetChanged(); after tabLayout.setupWithViewPager(viewPager); TabLayout is scrolling to unknown x position so the current tab is not visible. However if I scroll to left to expecting tab, this tab has indicator. What is going on? Could anyone help me? I have spent on it too many time. Below the code. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

TabLayout ViewPager Not Loading When Using Backstack [duplicate]

。_饼干妹妹 提交于 2019-12-03 14:21:49
This question already has an answer here: Lifecycle of a replaced ViewPager and BackStack? 1 answer I'm using a TabLayout in one of my fragments with a viewPager to switch between two fragments below the tabs. When I click the FAB inside one of the lower fragments, I load a new fragment (for input). However- when I press the BACK button, the TabLayout shows up but WITHOUT either of the lower fragments (represented by the pages). So what am I doing wrong? and is there a better way to be swapping fragments ? and is there a way to press the back button and get back to the viewPager Page that was

Android TabLayout does not display contents anymore as soon as fragment is switched

为君一笑 提交于 2019-12-03 12:22:32
I am using a navigation drawer in my project, with 5 fragments in it. In one fragment I have the in the design support library introduced TabLayout, which includes 2 Fragments. All works fine, except when I leave the fragment which has the TabLayout and switch back to it, all the content is gone. In each fragment in the TabLayout I have a SwipeRefreshLayout with a ListView in it, they both don't display anything upon switch. I also noticed the TabLayout starts acting strange. by strange I mean the white indicator starts jumping, you are able to hold it still in the middle of the two tab... So

IllegalStateException: Can't change tag of fragment was android:switcher now android:switcher

∥☆過路亽.° 提交于 2019-12-03 10:16:34
My activity uses TabLayout + ViewPager . The number of tabs and pages here are dynamic depending on the data fetch from the server. The crash are reported via Crashlytics, I'm not able to replicate it. My Activity code: @Override protected void onCreate(Bundle savedInstanceState) { boolean isAppRestarting = PrefUtils.getBoolean("app_restarting", false); if (isAppRestarting) { super.onCreate(null); this.savedInstanceState = null; } else { super.onCreate(savedInstanceState); this.savedInstanceState = savedInstanceState; } initSlidingTabs(); fetchSomeData(); // see onDataFetched() below } private

Android TabLayout: distribute evenly

Deadly 提交于 2019-12-03 09:59:13
问题 I'm looking at the Google class that was used in the Google IO called SlidingTabLayout. Inside that class, there is a method called setDistributeEvenly which allows all those tabs to have an even distribution on the screen - every tab has the same size: Align-Center SlidingTabLayout I'm trying to do the same with the official tabLayout class: https://developer.android.com/reference/android/support/design/widget/TabLayout.html But there doesn't seem to be a method available to make all the

Android TabLayout: distribute evenly

て烟熏妆下的殇ゞ 提交于 2019-12-03 01:32:41
I'm looking at the Google class that was used in the Google IO called SlidingTabLayout. Inside that class, there is a method called setDistributeEvenly which allows all those tabs to have an even distribution on the screen - every tab has the same size: Align-Center SlidingTabLayout I'm trying to do the same with the official tabLayout class: https://developer.android.com/reference/android/support/design/widget/TabLayout.html But there doesn't seem to be a method available to make all the tabs evenly distributed. Am I missing something and is there a method within the class which will let me

Use Tab layout in MVVM architecture with the data binding library

二次信任 提交于 2019-12-02 19:29:34
I am developing an app that has tab layout as the image. I’d like to use MVVM architecture with data binding library but I am new with this framework. I can do this without using MVVM by normally setup tab layout using ViewPager as this sample. Normal tab layout without MVVM and data binding: activity_main.xml: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android

Send Data from Activity to TabLayout fragments

只愿长相守 提交于 2019-12-02 16:23:40
问题 I am designing a application in which i am facing problem, I have a String date; in MainActivity.class and there are two fragments. InboundDate & OutboundDate I designed it by TabLayout & ViewPager, I am getting issue when i sending date to fragments & have to call WebServices by POST request on both the fragments. Below is the date i have in MainActivity.class, How i send this date to both the fragments & call jsonRequest and set Recyclerview to both the fragments Or if i call the

Android Tab layout: Wrap tab indicator width with respect to tab title

大城市里の小女人 提交于 2019-12-02 16:18:35
Is there any way to wrap tab indicator width with respect to tab title ? Yes , it's possible to wrap tab indicator as title setting padding to 0 public void wrapTabIndicatorToTitle(TabLayout tabLayout, int externalMargin, int internalMargin) { View tabStrip = tabLayout.getChildAt(0); if (tabStrip instanceof ViewGroup) { ViewGroup tabStripGroup = (ViewGroup) tabStrip; int childCount = ((ViewGroup) tabStrip).getChildCount(); for (int i = 0; i < childCount; i++) { View tabView = tabStripGroup.getChildAt(i); //set minimum width to 0 for instead for small texts, indicator is not wrapped as expected