android-tablayout

Different tabMode for TabLayout

怎甘沉沦 提交于 2020-01-12 17:56:12
问题 I`m using ViewPager and TabLayout. If tabs can be placed on the display tabMode they must be: app:tabMode="fixed" else app:tabMode="scrollable" How can I do this? 回答1: I din't get your question but i may help you, if tabs count is static or fixed(you know number of tabs) then app:tabMode="fixed" if tabs count is dynamic(data coming from feed) then app:tabMode="scrollable" 回答2: If the problem is that for certain screen configurations (e.g. small screens, portrait config, etc.) the tabs need to

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

怎甘沉沦 提交于 2020-01-11 02:28:06
问题 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

Android rtl viewpager with rtl tablayout

≡放荡痞女 提交于 2020-01-10 06:08:09
问题 I know this question may seem duplicated but i couldn't find a good solution for my problem. I am using tablayout with viewpager with fragmentPagerAdapter as adapter of viewpager. As you know viewpager is not supporting rtl layout so i have problems in rtl locales. I want to tabs start from right (first tab stick to right side of screen) and user can swipe correctly. How can i do this? Any help? 回答1: I have faced this case before and there are 2 solutions 1- let us assume that you have 4

android center align the selected tab in tablayout

与世无争的帅哥 提交于 2020-01-09 05:18:16
问题 I am using android support design tablayout. Here's my code: <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content"" app:tabGravity="center" app:tabMode="scrollable" /> <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" /> My issue is the tabs always align left. However, I would like to center the selected tab (even at the

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

蹲街弑〆低调 提交于 2020-01-08 18:20:15
问题 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 回答1: 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" /> 回答2: I

Android Studio call fragment method from other fragment or activity

时光总嘲笑我的痴心妄想 提交于 2020-01-07 08:31:52
问题 New Question abaut this: Android Studio Refresh Error I want call a Method in a Fragment from another Fragment. I have already tried this: (Tab3Storage) (getSupportFragmentManager().findFragmentById(R.id.tab3storage)).Storagerefresh(); but I have a NullPointerException error. How I can make this or a calling form a activity to the Fragment, because the calling from the Fragment to the Activity works already fine. Code: Main Activity: public void refreshAll(){ Tab3Storage tab3Storage = new

Android Studio call fragment method from other fragment or activity

天大地大妈咪最大 提交于 2020-01-07 08:31:36
问题 New Question abaut this: Android Studio Refresh Error I want call a Method in a Fragment from another Fragment. I have already tried this: (Tab3Storage) (getSupportFragmentManager().findFragmentById(R.id.tab3storage)).Storagerefresh(); but I have a NullPointerException error. How I can make this or a calling form a activity to the Fragment, because the calling from the Fragment to the Activity works already fine. Code: Main Activity: public void refreshAll(){ Tab3Storage tab3Storage = new

Android - tablayout with custom view tabs - drawable selector cannot be applied

六眼飞鱼酱① 提交于 2020-01-07 04:49:07
问题 I am trying to set up custom tabs in a tablayout using compile 'com.android.support:design:25.3.1' in gradle. I want to use selectors so that when a tab is clicked it changes based on its state. So I've tried the following unsuccessfully : this is my activity xml: <ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/white"/> <android.support.design.widget.TabLayout android:id="@+id/tabLayout"

Android Fragment isn't accepting setcontentview

試著忘記壹切 提交于 2020-01-07 02:55:23
问题 I am trying to use fragments to make swiped tabs by tablayouts (one activity with three tabs), I made three Java files for the tree tabs and the corresponding xml files as the below tutorial and it is working and I had the three tabs. but I stuck now in how to apply any code for any object inside these tabs .. should it be in the tab java file? if yes, the onCreateView method isn't accepting (findviewbyid) and I tried to add onCreate method but it is not accepting (setContentView) I also

Android ViewPager displaying views on top of TabLayout

一世执手 提交于 2020-01-06 04:23:21
问题 I am trying to set up two tabs in my TabLayout. The first tab is to display the profile, and the second tab is to display activity. I have the TabLayout and ViewPager setup. I also created the needed adapter to link the two fragments into the tablayout. When I run this on my phone, the two screens and tabs do display, but they do not display within the tab area - they cover up the actual tabs. I am using the design support library (v23.1.1) I have a main activity file with a fragment area