android-tablayout

Tab not taking full width on Tablet device [Using android.support.design.widget.TabLayout]

余生颓废 提交于 2019-11-26 23:22:32
I have setup tabs as UPDATE 29/05/2015 this post. Tabs take full width on my Nexus 4 mobile but on nexus 7 tablet it in center and not cover full screen width. Nexus 7 screenshot Nexus 4 screenshot Adam Johns A "simpler" answer borrowed from Kaizie would just be adding app:tabMaxWidth="0dp" in your TabLayout xml: <android.support.design.widget.TabLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:tabMaxWidth="0dp" app:tabGravity="fill" app:tabMode="fixed" /> Kaizie I had the same problem and I checked the TabLayout style, and i found that its default style is

ViewPager + RecyclerView issue in android

半城伤御伤魂 提交于 2019-11-26 23:12:20
Hi I have Tablayout with Viewpager and i am using Fragment for tablayout. Now in every Tablayout fragments I have Recyclerview and displaying items.Please See this my json response http://pastebin.com/nUswad9s here in "typeMaster": array i have categories "typeName": "Dogs", and i am displaying typenames in tablayout i have 4 tablayout, and inside typemaster i have subcategoreis named "catMaster": and i am trying to display catmaster data in recyclerview,but the issue is in every fragment it shows last data "catName": "Vitamins & Minerals", Activity public class CategoriesActivity extends

Changing the background color of a Tab in TabLayout (Android design support library) doesn't occupy the entire tab space

青春壹個敷衍的年華 提交于 2019-11-26 20:03:58
I have a TabLayout (design support library) which is tied up to a ViewPager containing three tabs. I have designed a custom layout and set that to each tab in the TabLayout. I have been trying to change the background color of the currently selected tab. The color only wraps up around the text in the tab but doesn't occupy the entire tab space. Below are the code snippets of my activity and the custom layout file. Activity code public class CustomTabLayoutActivity extends AppCompatActivity { private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super

Change the font of tab text in android design support TabLayout

喜欢而已 提交于 2019-11-26 19:47:58
I'm trying to work on the new TabLayout from the android design library. I want to change tab text to custom font . And,I tried to search some styling related to TabLayout ,but ended up to this . Please guide how can I change the tab text fonts. Farmaan Elahi Create a TextView from Java Code or XML like this <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@android:id/text1" android:layout_width="match_parent" android:textSize="15sp" android:textColor="@color/tabs_default

How to select next tab from child fragment

[亡魂溺海] 提交于 2019-11-26 18:41:36
问题 I need to switch next tab, when a button is clicked from a child fragment. This is how I setup tabs in parent, TabAdapter adapter; private void setUpTabs(ViewPager viewPager) { adapter = new TabAdapter(getSupportFragmentManager()); adapter.addFragment(new FirstTabFragment(), "First Tab"); adapter.addFragment(new SecondTabFragment(), "Second Tab"); viewPager.setAdapter(adapter); } And my TabAdapter class is, public class TabAdapter extends FragmentPagerAdapter { private final List<Fragment>

How do I change a tab background color when using TabLayout?

只谈情不闲聊 提交于 2019-11-26 18:30:50
This is my code in the main activity public class FilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_filter); // Get the ViewPager and set it's PagerAdapter so that it can display items ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); PageAdapter pageAdapter = new PageAdapter(getSupportFragmentManager(), FilterActivity.this); viewPager.setAdapter(pageAdapter); // Give the TabLayout the ViewPager final TabLayout tabLayout = (TabLayout) findViewById(R.id

TabLayout not filling width when tabMode set to 'scrollable'

拜拜、爱过 提交于 2019-11-26 18:05:23
问题 I have added TabLayout (from support library v22.2.1) to my Fragment as: <android.support.design.widget.TabLayout android:id="@+id/tabs" style="@style/MyColorAccentTabLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabMode="scrollable"/> The issue is that when the Fragment's orientation is landscape (before or after the initial creation of the fragment), the TabLayout doesn't match the width of the Fragment (yes the parent has its width set to match_parent

android:textAllCaps=“false” not working for TabLayout design Support

南楼画角 提交于 2019-11-26 17:31:46
问题 I have set android:textAllCaps="false" in my android.support.design.widget.TabLayout thought it is showing the Tab Title in All caps only. How can I remove all caps? 回答1: UPDATE FOR DESIGN LIBRARY 23.2.0+ The original answer doesn't work with design library 23.2.0 or later. Thanks for @fahmad6 pointed out in comment, in case someone missed that comment, I'll put it here. You need to set both textAllCaps and android:textAllCaps to false to disable all capitalize setting. <style name=

How do you create an Android View Pager with a dots indicator?

£可爱£侵袭症+ 提交于 2019-11-26 16:57:28
Probably many of you (as me), have problem with creating ViewPager with bottom dots, like this: How do you create such an Android ViewPager? RediOne1 All we need are: ViewPager , TabLayout and 2 drawables for selected and default dots. Firstly, we have to add TabLayout to our screen layout, and connect it with ViewPager . We can do this in two ways: Nested TabLayout in ViewPager <android.support.v4.view.ViewPager android:id="@+id/photos_viewpager" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.TabLayout android:layout_width="match

Different tab width for TabLayout

时光毁灭记忆、已成空白 提交于 2019-11-26 15:49:49
问题 I'm using TabLayout & ViewPager. I am trying to change the size of the Tab, like Whatsapp (camera icon). The size of the three Tabs is equal, but the Tab of the camera is smaller. In every attempt I make the size of the Tabs remains the same (equal across all tabs). Thanks. 回答1: You need to lower the weight of the LinearLayout of the corresponding tab. LinearLayout layout = ((LinearLayout) ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(YOUR_TAB_NUMBER)); LinearLayout.LayoutParams