android-tablayout

Design support library tabs with only icons

一个人想着一个人 提交于 2019-11-29 08:07:00
I am using design support library to create tabs. By default it creates tabs with text. How can I create tabs with only icons? Also I want to change the icons color if it's current selected tab. Use this to populate the viewPager: public class SectionPagerAdapter extends FragmentPagerAdapter { public SectionPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { switch (position) { case 0: return mFragmentA; case 1: return mFragmentB; case 2: return mFragmentC; default: return null; } } @Override public int getCount() { return 3; } @Override public

Align Icons in Tab Layout To The Left

扶醉桌前 提交于 2019-11-29 07:36:25
Hello I have created a tab layout in my activity. This is the main .xml file: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/main_layout" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.xxxxxx.eventmanager.EventDetailsActivity"> <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id

TabLayout with ViewPager not working inside fragment Android

空扰寡人 提交于 2019-11-29 07:27:31
Hi I have a TabLayout and ViewPager inside a fragment. But I can not slide beetween tab to come to child fragment (Working normally when in Activity but not work in fragment). Here is my code for Tablayout inside fragment: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflateView = inflater.inflate(R.layout.fragment_assign_beacon_to_event, container, false); //Viewpager and TabLayout viewPager = (ViewPager)inflateView.findViewById(R.id.viewPager); viewPager.setAdapter(new CustomAdapter(getFragmentManager(), getContext()));

OnResume() not called in Fragment using tabLayout and ViewPager

自闭症网瘾萝莉.ら 提交于 2019-11-29 06:36:59
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.setTabGravity(TabLayout.GRAVITY_FILL); final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

Define TabLayout style in theme

笑着哭i 提交于 2019-11-29 05:56:10
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 find any info which item name should I use to build my theme. I'd like to add the TabLayout the same way I

Cannot remove Padding from Tabs when using Custom views with Tab Layout

不想你离开。 提交于 2019-11-28 22:51:24
I have added a Relative Layout in Custom View and have added this in Tab Layout. I am using a white background for tabs and have not applied any padding in tabs custom layout. But then also I am getting padding on tabs due to which I am shown some grey background within tabs as if android is internally applying padding to tabs. I am trying to display three text views which I am able to do but one of them is truncating because of padding applied to tabs. Also I want to have consistent background color for tabs. Here is my layout code: activity_home.xml <?xml version="1.0" encoding="utf-8"?>

Android: pin TabLayout to top of Scrollview

孤街醉人 提交于 2019-11-28 21:17:24
问题 I was looking at the twitter app on my phone. You can see that when a user scrolls up, the tabLayout actually just pins itself onto the bottom of the toolbar nicely and does not move at all. I thought maybe they did it by just putting all of the top part of the app (the profile picture, the profile wallpaper of the bicycle on the grass, the text), into a CollapsingToolBarLayout and AppBarLayout but actually, only the profile wallpaper with the bicycle on the grass is part of the

Hiding/Showing the toolbar when fragment in the tabs is scrolled

吃可爱长大的小学妹 提交于 2019-11-28 17:34:28
I added the new Toolbar , Tablayout and Viewpager in my android app. I provided Fragments for my 3 Tabs and its working fine. But the problem is that when i scroll up my Toolbar does not hide. I want that when i scroll my fragment it should hide. And one more thing, i am using Webview in the fragment. My codes are given below. MainActivity.Java public class MainActivity extends AppCompatActivity { TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setupToolbar(); setupTablayout(); } private void

Dynamically add and remove tabs in TabLayout(material design) android

不问归期 提交于 2019-11-28 17:12:36
I have a TabLayout and inside that I have ViewPager. I need to dynamically add and remove tab in tablayout(material design). I can able to add the tabs dynamically but while removing the tab, tab is removing correctly. But viewpager last item is deleted. So tab is not showing specific fragment. FYI i have used FragmentPagerAdapter. I have followed this tutorial to implement this https://androidbelieve.com/navigation-drawer-with-swipe-tabs-using-design-support-library public class TabFragment extends Fragment { public static TabLayout tabLayout; public static ViewPager viewPager; public static

Changing TabLayout icons on left, top, right or bottom in com.android.support:design:23.1.0

与世无争的帅哥 提交于 2019-11-28 17:12:15
问题 I'm pretty new to android development. So bear with me. I've been trying to align the icon and text in same line in com.android.support:design:23.1.0 for a day. Apparently in com.android.support:design: 23.1.0 they've changed the default icon position to top and text on the bottom. Previously in com.android.support:design: 23.0.1 the default was the icon on left and text in same line as the icon So here's an easy way to solve it (though it might have drawbacks, idk tbh): change the version in