android-tablayout

Tablayout with icons only

感情迁移 提交于 2019-11-27 09:31:19
问题 I am using design support to create tabs. I am also using ViewPager for swipable tabs. Now, I don't know how to use only icons instead of texts in tabs. I tried finding out but didn't get any success. My code: Toolbar toolbar; private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.pager); setupViewPager

android center align the selected tab in tablayout

♀尐吖头ヾ 提交于 2019-11-27 09:06:47
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 beginning, the first(selected) tab should be centered). Is there a way to do this? Thanks. I took a look

Android ViewPager Loading incorrect fragments

戏子无情 提交于 2019-11-27 07:09:21
问题 So I'm trying to get a tab bar and layout underneath my main navigation bar working on my main activity. I can't seem to get the ViewPager/TabLayout (unsure which is the cause of the problem, new to this) to load the correct fragment. I've read through a ton of documentation and checked more than 1 tutorial to see if I was doing this correctly and it seems that I'm doing the same thing they are... The OnTabSelectedListener for my TabLayout is seeing the tab changes properly, and in

Text size of android design TabLayout tabs

你。 提交于 2019-11-27 06:39:21
I have difficulties changing the text size of the tabs of design library tablayout (android.support.design.widget.TabLayout). I managed to change it by assigning tabTextAppearance in TabLayout app:tabTextAppearance="@style/MyTabLayoutTextAppearance" the following style <style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"> <item name="android:textSize">14sp</item> </style> but I have 2 side effects : 1) I lost the accent color of the selected tab 2) The tab text is not capitalized any more. hnrain <style name="MineCustomTabText" parent=

Using TabLayout inside a Fragment; tab text invisible

蹲街弑〆低调 提交于 2019-11-27 05:29:38
问题 I'm currently experimenting with various new components in the new Android Support Design library. I've implemented a NavigationView in my MainActivity.java , which uses a FragmentManager to navigate between the items in the Navigation drawer: getSupportFragmentManager() .beginTransaction() .replace(R.id.content, mTabLayoutFragment) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .commit(); I'm using a TabLayout in one of the fragments. Here is the fragment's layout: <android

Android Tablayout tabs with notification badge like whatsApp

别来无恙 提交于 2019-11-27 04:21:04
问题 I want to implement notification badge with android.support.design.widget.TabLayout . I had tried my best effort to implement it but fails. Any help would by greatly appreciated. 回答1: My solution to this was using https://github.com/jgilfelt/android-viewbadger and setting a custom view to each tab: My tabs have only icons so I used ImageView, but I believe you can use any other view, check https://github.com/jgilfelt/android-viewbadger/blob/master/README.markdown: private BadgeView badge; Tab

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

自作多情 提交于 2019-11-27 03:52:45
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? Paresh Mayani 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="MyCustomTextAppearance" parent="TextAppearance.Design.Tab"> <item name="textAllCaps">false</item> <item

How to add margin between tabs in TabLayout?

社会主义新天地 提交于 2019-11-27 03:24:28
问题 Is there a way to add margin between the tabs in a TabLayout? I've tried with using a custom style for Widget.Design.TabLayout , but there are properties only related to padding, but no margins. 回答1: Ok mates, after spending 2-3 hours on that I finally found a solution. If you are using TabLayout there is no way to add margins to the tabs by using styles and so on. (as @Connecting life with Android earlier) But, you can do that by writing some Java code. All in all your code should look

Difference between PagerTabStrip and TabLayout

醉酒当歌 提交于 2019-11-27 02:35:29
问题 I am working on an app where I want to add tabs so that can be added using PagerTabStrip and TabLayout with ViewPager. It looks same to me with no difference but I guess there is some difference between them so they are two classes for this. So what is the main difference between them? 回答1: Just comparing the visuals... TabLayout is a material concept that replaced the deprecated ActionBar tabs in Android 5.0. It extends HorizontalScrollView , so you can keep adding tabs horizontally which

TabLayout tabs text not displaying

笑着哭i 提交于 2019-11-27 01:26:33
问题 I am using TabLayout inside a Fragment to display three fixed tabs and the tabs are working but it doesn't show the tab text even after I set the app:tabTextColor attribute in the layout it's still not visible. NewFragment.java public class NewFragment extends Fragment { private RecyclerView mRecyclerView; private RecyclerView.LayoutManager mLayoutManager; private RecyclerView.Adapter mAdapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle