android-tablayout

TabLayout: How to load all the tabs or only swipe refresh occur

≯℡__Kan透↙ 提交于 2020-03-22 05:49:58
问题 I have an activity and i implement the android TabLayout with recyclerview. I implemented three fragments for the three tabs of the TabLayout. The default load behavior of the TabLayout it will load and cache the neighbor tab but not the one that already loaded. let's say Fragment A, B and C correspond to tab 1, 2 and 3 respectively. When users visit tab 1 ---> Fragment A and B loaded When users visit tab 2 ---> Fragment C loaded But when users visit tab 1 again --> Fragment A load again.

ViewPager2 preloaing next fragment even when offsetlimit is the default(0)

*爱你&永不变心* 提交于 2020-03-05 01:30:40
问题 I am facing this rather strange problem with viewPager2. I did some reading and found out that viewPager2 has a default offset limit of 0 which is perfect for my application. I'm using it with a tab layout and I have 3 fragments (Home, Profile, Notification). When the activity loads and the first fragment(Home) loads, I can see in my logcat that the next fragment(Profile) is not loaded, as expected. But when I click on the profile tab something strange happens, the next tab(Notification) is

Tabbar layout active tab textcolor is same as primary color

断了今生、忘了曾经 提交于 2020-03-03 07:07:39
问题 This is my style: <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme

Scrollview not working when it has viewpager in android

人走茶凉 提交于 2020-02-06 09:07:07
问题 In my activity we have view pager which shows tabs and other views at top. ViewPager tabs shows different Fragments. Below is the code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/root" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <LinearLayout android:layout

TabLayout gravity center is not working

ぃ、小莉子 提交于 2020-02-01 23:58:28
问题 I have a TabLayout, where I want the tabs to be displayed in the center of the screen. Below is the XML for my TabLayout. <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@color/white" app:tabGravity="center" app:tabIndicatorColor="@color/about_tab_selected" app:tabIndicatorHeight="4dp" app:tabMode="scrollable" app:tabPaddingEnd="20dp" app:tabPaddingStart

TabLayout ViewPager Not Loading When Using Backstack [duplicate]

百般思念 提交于 2020-01-31 11:07:05
问题 This question already has an answer here : Lifecycle of a replaced ViewPager and BackStack? (1 answer) Closed 4 years ago . 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

how to avoid hiding the tabs when scrolled down?

亡梦爱人 提交于 2020-01-25 03:39:09
问题 I have implemented viewpager with TabLayout. Each tab is a Fragment. I think the default behavior of Tabs is that they are hidden when user scrolls down and gets visibility when scrolled up. I wont have much content to make use of the tabs space too. So I want to show the tabs always. How can I avoid hiding the Tabs when user scrolls down ? Here is my TabLayout with ViewPager: <android.support.design.widget.AppBarLayout android:id="@+id/myAppBarLayout" android:layout_width="match_parent"

Android - TabLayout in AndroidX

杀马特。学长 韩版系。学妹 提交于 2020-01-24 19:57:45
问题 I just tried to implement tabLayout on Android with androidX and im not able to do it. Is tabLayout on androidX deprecated? 回答1: You need to add material library as a dependency to build.gradle file to use TabLayout dependencies { implementation 'com.google.android.material:material:1.0.0' } also inclue google() maven repository to the repositories section of the root build.gradle allprojects { repositories { google() jcenter() } } You can read the Getting started with Material Components for

Changing the icon of selected tab

喜欢而已 提交于 2020-01-24 09:50:26
问题 Im setting the tablayout as follows, private void setupTabIcons() { TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabOne.setText("Status"); tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.status, 0, 0); tabLayout.getTabAt(0).setCustomView(tabOne); TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabTwo.setText("Rating"); tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.rateit, 0, 0)

Communicating between the tablayout Fragments [duplicate]

本秂侑毒 提交于 2020-01-22 04:06:00
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 months ago . I used a tab layout with fragment. The scenario goes like this. Activity: Fragment 1 , Fragment2 , Fragment3 From Fragment2 Updating the UI of Fragment1. I tried to access the methods from fragment but resulting null pointer exception . 回答1: You may use Observer Pattern to achieve this. To do this, You have to create a MutableLiveData in your MainActivity and pass