android-tablayout

Remove the shadow below TabLayout on android

試著忘記壹切 提交于 2019-12-21 07:54:23
问题 I'm trying to remove the shadow below tabs while using TabLayout, which is defined in a normal layout (and not as a part of a toolbar or actionbar). Setting theme as <item name="android:windowContentOverlay">@null<item/> or <item name="windowContentOverlay">@null<item/> didn't work. Also, setting elevation to 0 didn't help either. <android.support.design.widget.TabLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/sliding_tabs" android:layout_width="match_parent"

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

别等时光非礼了梦想. 提交于 2019-12-20 08:36:21
问题 Is there any way to wrap tab indicator width with respect to tab title ? 回答1: 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 =

Inflating AppBarLayout with Toolbar + TabLayout

让人想犯罪 __ 提交于 2019-12-20 08:36:08
问题 I currently have a DrawerLayout in my main.xml. There's a Toolbar wrapped in an AppBarLayout, and then a simple LinearLayout to swap out fragments. One of the fragments I navigate to, I want it to contain a TabLayout for a ViewPager of fragments. Currently, I have both of these in the fragment's layout file, but this causes a drop shadow to appear between the Toolbar and the TabLayout, which is something I don't want. I also don't want to use setElevation() because it won't work for pre

TabLayout not showing tabs after adding navigation bar

為{幸葍}努か 提交于 2019-12-20 05:13:34
问题 i am working with ViewPager + TabLayout. It was working fine, but after i added navigation bar, the TabLayout is not showing tabs. I searched for solution but none of them helped. It will be really helpful if anyone tells me why this happened. MainActivity.java ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); SimpleFragmentPageAdapter adapter = new SimpleFragmentPageAdapter(this, getSupportFragmentManager()); viewPager.setAdapter(adapter); TabLayout tabLayout = (TabLayout)

TabLayout not showing tabs after adding navigation bar

眉间皱痕 提交于 2019-12-20 05:13:03
问题 i am working with ViewPager + TabLayout. It was working fine, but after i added navigation bar, the TabLayout is not showing tabs. I searched for solution but none of them helped. It will be really helpful if anyone tells me why this happened. MainActivity.java ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); SimpleFragmentPageAdapter adapter = new SimpleFragmentPageAdapter(this, getSupportFragmentManager()); viewPager.setAdapter(adapter); TabLayout tabLayout = (TabLayout)

Stop Android TabLayout loading next page automatically

Deadly 提交于 2019-12-20 03:55:09
问题 I've realized when using a tab layout in Android it always loads the tabs touching it, i.e. the tab before and the tab after so it is loaded when you page to it. However, I load lots of content and images from a server and this causes a lot of data and memory use and I often get OOM errors , I am displaying the images efficiently using Glide. Basically I need to know 3 things: How can I stop the tab layout loading any pages other than the current one How to clear/recycle/delete an old tab

I need to assign a unique tab id to my tabs created using viewpager and tablayout?

家住魔仙堡 提交于 2019-12-19 17:41:27
问题 I created an Tab based application using viewpager and Tablayout. When i click a button new tabs are created with a child fragment. What I need is to assign different tab id to my tabs and each should be different. I tried i take the position of tabs but unfortunately, it doesn't work. when i tried to toast the position using below code it works only initially when the first tab is created and doesn't work for other tabs created. I don't know why this happens. ALso if i delete the tabs the

Check fragment visibility after clicking on Tab from TabLayout that only contains icon using Android Espresso

自作多情 提交于 2019-12-19 09:57:45
问题 I'm trying to check if my fragment is visible after performing a click on my tab from my tabLayout which has been set up with view pager. This is my actual activity code, inside my activity onCreate method: mViewPager = findViewById(R.id.contentFrameLayout); mViewPager.setAdapter(mSectionPageAdapter); mViewPager.setPagingEnabled(false); //Set up the tab layout to display tabs tabLayout = findViewById(R.id.homeTabs); tabLayout.setupWithViewPager(mViewPager); for (int i = 0; i< tabLayout

How to set icon next to text in tablayout

安稳与你 提交于 2019-12-19 06:45:05
问题 I am working on Tablayout with text and icon from the following tutorial .. My question is how to make the icon placed next to the text instead of above them? I am new in Android Development, hopefully you guys can help me out. Thank you in advance, really appreciate the answer.. Here is my java file public class AllProducts extends AppCompatActivity { public ViewPager viewPager; public TabLayout tabLayout; public int[] tabIcons = { R.drawable.ic_directions_car_white_24dp, R.drawable.ic

Tab change listener android

拥有回忆 提交于 2019-12-19 05:03:45
问题 My HomeActivity extends AppCompatActivity that uses 2 tabs. public class HomeActivity extends AppCompatActivity { private SectionsPagerAdapter mSectionsPagerAdapter; private TabLayout tabLayout; ... @Override protected void onCreate(Bundle savedInstanceState) { ... mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); } ... How to listen to tab change event? Let me know if I