Android Xml command meanings? - android

Hi my question is related to some xml commands used in material design designs. I don't understand what some commands mean in Toolbar and TabLayout. Is there anyone have an idea? What do the numbers of commands mean?
Toolbar
app:layout_scrollFlags="5"
TabLayout
app:tabGravity="0"
app:tabMode="1"

You should look at the official docs
For tabGravity
GRAVITY_CENTER Gravity used to lay out the tabs in the center of the TabLayout.
GRAVITY_FILL Gravity used to fill the TabLayout as much as possible. This option only takes effect when used with MODE_FIXED.
MODE_FIXED Fixed tabs display all tabs concurrently and are best used with content that benefits from quick pivots between tabs. The maximum number of tabs is limited by the view’s width. Fixed tabs have equal width, based on the widest tab label.
MODE_SCROLLABLE Scrollable tabs display a subset of tabs at any given moment, and can contain longer tab labels and a larger number of tabs. They are best used for browsing contexts in touch interfaces when users don’t need to directly compare the tab labels.
For tabMode ="fixed" or "scrollable"
MODE_FIXED: Fixed tabs display all tabs concurrently and are best used with content that benefits from quick pivots between tabs.
MODE_SCROLLABLE: Scrollable tabs display a subset of tabs at any given moment, and can contain longer tab labels and a larger number of tabs. They are best used for browsing contexts in touch interfaces when users don’t need to directly compare the tab labels. This mode is commonly used with a ViewPager.
For scrollFlags -> here

Related

Fixed number of tabs per page in TabLayout

I am using scrollable TabLayout with a ViewPager.
I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3.
I can't find a property to control the number of tabs displayed.
Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget.TabLayout

Fragment layout ambiguity

I have a project with 99 fragments. A client wants us to make our BottomNavigationView semi-transparent and have our content scroll behind it. But not all our fragments are scrollable. Some are RelativeLayouts with controls attached to the bottom of the page that need to not allow themselves to go down past the BottomNavigationView, so that they're not covered up. And even with the pages that scroll, sometimes it's not even the entire page that scrolls, but just a subset of it. Is there any way I can achieve this kind of ambiguity without going through all 99 of my fragments and making a unique judgement call on each or them?
There is no direct solution as such for what you are trying to achieve.
If your fragments has RecyclerView then add extra bottomSpacing for last item in the list in ItemDecoration class.
If your fragment has ScrollView then add extra paddingBottom for last view in the hierarchy.
If your view has anything other than these two scrolling views, then you can hardcode the bottom margin and give a color below matching to the navigation view. This make it look opaque from translucent.
One thing that is understood is the bottom spacing, margin and padding will be equal to or slightly greater than (ideally height + 8dp) you bottom navigation.
Since you fragments behave differently, there is no use of trying to make single solution for the same. But to make the job easier for future, you can externalise these margins and spacings in dimens.xml (use same object for all the spacing) and hence in future if any requirement changes, you can change the spacing directly from the dimens.
And you can do the same for bottom navigation spacing color, externalize to colors.xml and change it as you like.

Split activity with adjustable children height

I am trying to create an activity layout with two parts, where their respective size is dynamic. The activity should have two states:
Starting state:
The user scrolls the bottom part up to the second state (and back):
It's important that the change will be animated. I tried a few solutions so far but didn't manage to find the exact way to do that:
AndroidSlidingUpPanel - The panel acts as another layout, covering the upper view and moving the toolbar out of the screen.
Android Split Pane Layout - Correct behavior, but the splitter is dragged and not the bottom part (I don't want to have a visible splitter).
CoordinatorLayout with CollapsingToolbarLayout - I didn't find a way to limit the upper part from totally disappearing. Anyway I think that it's a bit abusing because I don't want to collapse a toolbar but just change the children's height with animation.
Is there a good way to implement this using another library, one of these that I perhaps didn't use correctly or with simple layouts? Thanks!
I found a custom version of the SlidingPaneLayout created by VLC, which is basically a vertical SlidingPaneLayout - the exact functionality that I was looking for.

How not to wrap the Tab Titles in Swipe View?

I am trying to create swipe able views in android.
But since titles of my Tabs are longs they are getting wrapped to fit in single screen.
How to avoid the wrapping of titles and let the titles extend in one line even if the tab titles has to expand outside the current screen.
Seen Image Here
There is an Android component for that called PagerTitleStrip: http://developer.android.com/training/implementing-navigation/lateral.html#PagerTitleStrip
This will provide you fully-visible scrollable tabs.

Android - Overlapping Adjacent LinearLayouts, Overlaying LinearLayouts

I am porting an iOS application so the design is pretty much out of my hand. What I have is two LinearLayouts, one with what is basically a bump (shown in pictures) that I want to overlap the second LinearLayout.
I get aesthetically what I want desire I use FrameLayout to contain the two layouts. However, here I run into two functional problems. The first, I need to be able to allow the bottom, overlapping LinearLayout which is composed of five adjacent image buttons to change size (preferably, using layout_weight). The second is anything that is in the bottom of the top LinearLayout it is hidden by the bottom LinearLayout.
When I switch to using LinearLayout, from FrameLayout to contain the two I get functionally what I want, however, aesthetically it smashes the button to fit.
Both cases are pictured. All feedback is appreciated. I am hoping to find a solution to this without designing a custom widget.
Thanks.

Categories

Resources