Can I change the swipe direction of Tabs in TabLayout by code?
It works fine when my device's language is English, But when I change it to Arabic, A lot of tabs disappear and the swipe's direction still the same (to The Right ).
Note: In Manifest file support RTL option is "true".
You can easily change layoutDirection. i had this problem too and fix by :
tabLayout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
Just try it!
There are two simple steps you need to follow:
Change the rotation of the View pager,
viewpager.setRotationY(180);
Then again change the direction of the fragment container which is the child of viewpager,
recyclerView.setRotationY(180);
The actual problem you facing is the fact, that ViewPager still does not support RTL.
It's well-known and very old issue - you can find it in Google's issue tracker:
ViewPager RTL swipe direction
So far, I haven't seen any successful examples of RLT's implementation. For, example, there's one from Booking.com, but it doesn't work with TabLayout yet. I'd suggest to dig into it and try to fix the issue there, than start writing it from scratch.
UPD: I forked Booking's RtlViewPager and fix it for TabLayout's. Feel free to try it!
This issue is well known and there is no ETA for a fix.
Use this code tabLayout.setTabMode(TabLayout.MODE_FIXED);
Related
Firstly, I would like to mention that since i am not sure of the terminology of the view that i am looking for so I shall try and explain the behaviour.
I am looking for build a screen with multiple tabs where the tab indicators do not fit all inside the screen so it is scrollable. This is fine but i want that when the scrolling happens, after the last tab indicator, the tab widget automatically shows the first tab indicator right after it. So kind of like a circular tab widget.
Could someone please give pointers on how this could be achieved in android.
Thanks,
Sunny
I'm not sure, since you're not so clear...but i think you're looking for this:
https://github.com/astuetz/PagerSlidingTabStrip
Sliding tabs like the ones in Google Play.
Has anyone managed to bring the items in a V4 PagerTabStrip together, more like Google Play Store?
http://developer.android.com/reference/android/support/v4/view/PagerTabStrip.html
This is what I want:
This is what i get (the space between segments):
These images are not mine but its just to explain what I mean.
Additionally the underline for the Strip, is it possible to have a different color then the selected item underline (v4).
Thanks
Edit: For all those asking if I ever found a solution, I never did. Sorry :-(
I'm also searching the answers to this questions and it seems not exist the api to do such thing in android-support-v4. But as an alternative, we can try this https://github.com/xiaopansky/PagerSlidingTabStrip . Not a perfect but time-saving solution.
So it's been a while on this topic but I believe there are people still searching for this answer so I wanted to put here what I've found.
https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabStrip.html
On Android's developer website, they have sample code on how to accomplish it yourself. I personally haven't tested it yet so not sure if it supports that exact look and feel or whether it supports customization but at least the code is there for yourself and you can play around with it. I'd really wish that v4 PagerTitleStrip and PagerTabStrip supported the above features by default.
The default PagerTitleStrip has only 3 textviews initialized. So if You wish to remove spacing create a custom PagerTitleStrip class and add more textviews so that space is reduced.
I'm trying to create an accordion in Android that has the following features:
Slide animation when opening a tab
Alignment to the top when opening a tab
The ability to be used inside a fragment and not inside an activity
Any idea to how to accomplish all these points? I've seen a lot of libraries that however luck of one or more of this points (and I cannot fix the remaining myself :( ).
Any idea? Also pointers to how-to-guides to how to fix the missing points would be really useful! Thanks
If you are interested on how I solved the problem, you can find the code here: https://github.com/filnik/AndroidSmoothAccordion
It is "quick-and-dirty" but it does the job.
Hi fellow android developers,
I'm trying to implement a multi-pane layout as described here and an example implementation can be found in the codesample "HoneycombGallery".
The only thing I changed is, that instead of using the normal getFragmentManager() I use the support-libraries and therefore the "getSupportFragmentManager()". But now I have the following problem:
The getSupportFragmentManager().findViewById() returns a reference to a fragment even when the fragment is not on the screen :/
As you cann easily see, the example implementation uses this technique to differ between the to possibilyties, but the getSupportFragmentManager() returns a reference to a fragment in situations (for example after a orientation change and the second fragment disappeared as it is no longer in the layout) where it shouldn't.
Has anyone also tried to get Multi-Pane-Layout working with the support-Fragments and FragmentManager?
Any hint is highly appreciated :)
Cheers
Ali3n
PS.: I could post some code if requested, but it actually is nearly the same code as in the example ...
I fixed my problem, by not asking the FragmentManager for the fragment, instead I ask my layout for the view.
I had the same problem and registered an issue on Android issue tracker.
http://code.google.com/p/android/issues/detail?id=40796
Please star if anyone having this issue.
I am pretty new at all this android java development to create apps but after a series of tutorial I feel more confident.
I have ideas for an app in which the layout would be like the phone app in android 4.0.3.
Let me explain : my app would.consist in three or four tabs where the user could switch between on to the other by swiping the finger left or right. The top of the layout would display the title of each tab and underline in blue the name current tab (same as the phone app does).
Does anyone have some hints or places where I could find some sample code ? Or even the code of the androidphone app ?
Thank you very much for your help.
David
http://www.pushing-pixels.org/2011/08/11/android-tips-and-tricks-swipey-tabs.html
http://blog.stylingandroid.com/archives/537
Is this what You are refering to ?
Your best bet would be to use ViewPager and TitlePageIndicator.
The ViewPager you can find on the compatibility package or on the ActionBarSherlock library (strongly recommend the last one which can be found here http://actionbarsherlock.com/) and TitlePageIndicator, found here https://github.com/JakeWharton/Android-ViewPagerIndicator)
Plus, by using the ViewPager you will learn a bit about Fragments which is very nice :)