android-tablayout

Android. Tablayout inside a tab of another tablayout

不羁的心 提交于 2019-11-30 22:35:09
Is it possible to have a tablayout inside a tab of another tablayout? I have created the following image for a better explanation. The slide movement desired is as it is described in the image. My main activity 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:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"

How to use TabLayout with ViewPager2 in Android

一世执手 提交于 2019-11-30 21:55:05
问题 I want to use com.google.android.material.tabs.TabLayout component with Android's new ViewPager implementation androidx.viewpager2.widget.ViewPager2 . However, the setupWithViewPager(..) method provided by TabLayout supports only the old ViewPager implementation. Is there a way to bind a TabLayout to a ViewPager2 component easily? 回答1: You have to use this TabLayoutMediator that mimics tabLayout.setupWithViewPager() and sets up the ViewPager2 with Tablayout . Otherwise you will have to write

android.support.design.widget.TabLayout select Tab Programmatically

三世轮回 提交于 2019-11-30 21:37:49
问题 I am using android.support.design.widget.TabLayout. It has two tabs, If user selects second tab On particular condition I want user to redirect to first tab and disallow him to go to sencond tab until condition matches. To achieve this I tried, tabLayout.getTabAt(0).select(); but it does not reselect first tab 回答1: This is because that view is still not initialized properly, and you are trying to perform some action. As a solution you just need to put one hadler before selecting perticular

Change icon and title color when selected in android design library TabLayout

懵懂的女人 提交于 2019-11-30 20:51:14
I am using TabLayout of design library what i want to acheive is I have tried many tutorial and i am able to achieve it by customizing the tab but there is an limitation that is occurring when the tab is selected i want to change the text color as well as the image of the icon which is not possible by referring any of the tutorial i read so far. I have tried this so far by adding this in the FragmentStatePagerAdapter public View getTabView(int position) { View tab = LayoutInflater.from(mContext).inflate(R.layout.tabbar_view, null); TextView tabText = (TextView) tab.findViewById(R.id.tabText);

Android Design Support Library TabLayout using custom tabs layout but layout wrapping the tabs

跟風遠走 提交于 2019-11-30 17:35:19
In tab custom layout I set its parent element to match_parent and set its background color. When I run it tabs are shown custom layout wrapping the elements imageview and textview. I want this custom layout will fill the tab without any space between tabs. Check output here: private void setupTabLayout(ViewPager viewPager, ViewPagerAdapter viewPagerAdapter) { TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout.setupWithViewPager(viewPager); int length = tabLayout.getTabCount(); for (int i = 0; i < length; i++) { tabLayout.getTabAt(i).setCustomView(viewPagerAdapter

Toolbar and TabLayout is not visible on Android 4.4 devices

心已入冬 提交于 2019-11-30 13:54:31
I was trying to implement Toolbar and TabLayout using google design library by referring to [ http://blog.grafixartist.com/material-design-tabs-with-android-design-support-library/] [blog]. Output works as expected on Lollipop devices but it doesnot show ToolBar and TabLayout on Kitkat devices. But i can still swipe through 3 fragment as expected on kitkat device as well. How come same code written using google support libraries works differently on different devices! I tried referring to [ Toolbar is not visible on Android 4.X devices [solved] question but it didn't solve the problem. I tried

OnResume() not called in Fragment using tabLayout and ViewPager

余生颓废 提交于 2019-11-30 08:27:13
问题 i'm developing an app using tabLayout . I've a problem: When I try to reactivate a Fragment , the method OnResume is non called. This is my activity: private void init() { fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Nuovo Ticket", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout

Solved - Android ViewPager and TabLayout are not working fast

霸气de小男生 提交于 2019-11-30 08:16:40
There are nested fragments with TabLayout and ViewPager . Each fragment has listview inside it so they get call together and now I'm getting an issue of slow processing of app. I have tried some solutions like volley library but it didn't work for me. For more I'm posting my code too so please guide me to make it best. MainTabFragment.java public class MainTabFragment extends Fragment { public static int position_child_tab = 0, three_childs_tab_position = 0; static int count = -1; int position_tab = 0; Bundle args; MyTabLayout myTabLayout; public MainTabFragment() { // Required empty public

Define TabLayout style in theme

旧街凉风 提交于 2019-11-30 08:01:58
问题 I have two different styles of TabLayout in my app: <style name="TabLayoutPower" parent="Widget.Design.TabLayout"> <item name="tabSelectedTextColor">@android:color/white</item> <item name="tabTextColor">@android:color/white</item> </style> <style name="TabLayoutFree" parent="Widget.Design.TabLayout"> <item name="tabSelectedTextColor">@android:color/black</item> <item name="tabTextColor">@android:color/black</item> </style> How can I define the default TabLayout style for a theme? I cannot

TabLayout with viewpager not smooth scrolling

寵の児 提交于 2019-11-30 07:52:43
Edit I have followed these tutorials to fix this problem. http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/ https://guides.codepath.com/android/google-play-style-tabs-using-tablayout http://www.voidynullness.net/blog/2015/08/16/android-tablayout-design-support-library-tutorial/ But its annoying that problem still persists after trying several solutions. Here is demo for the problem i am facing.Its been weeks since i am stuck on this problem. Link for demo. Devices i am using for the testing are Nexus 4 and Nexus 5. TabLayout with ViewPager isn't scrolling smooth. I need