Pin collapsingtoolbar child - android

app:layout_collapseMode="pin"
This attribute seems to only work if the view is a toolbar and won't work on other views such as relativelayout, why?

app:layout_collapseMode= "pin"
pin is set to this mode, the Toolbar can remain on the screen when the CollapsingToolbarLayout is fully shrunk.
Fixed mode, finally fixed at the top of the fold
Because it was CollapsingToolbarLayout's attribute .
And it also used in CoordinatorLayout .

Related

CoordinatorTabLayout without collapse functionality

Im searching for a specific Layout which I couldnt find in the internet. It somehow looks like a CoordinatorTabLayout but without collapsing while scrolling down/up. I founded this View in the App "BlackMusicPlayer" which looks like this:
When youre going to tap on the Picture the View is expanding. Should I create a new Layout from scratch or is there anything out there I could youse? Thank you
CoordinatorTabLayout is a custom composite control that quickly implements the combination of TabLayout and CoordinatorLayout.
may this github sample helps you
you can get reference of appBarLayout and try this
AppBarLayout.LayoutParams p = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
p.setScrollFlags(0);
toolbar.setLayoutParams(p);
Use coordinator layout with collapsing toolbar , and this will keep the collapsing toolbar always expanded

Collapsing toolbar anchored view is hidding when collapse

I need to display a TextView (The circular shape with "0") anchored to the toolbar, like a FAB, but it must be ALWAYS VISIBLE.
My problem is that when I collapse the toolbar (scrolling the recyclerView), at the fully collapsed state, it hides the half of the view...
The TextView layout has this properties:
app:layout_anchor="#id/appbar"
app:layout_anchorGravity="bottom|center_horizontal"
Anyone knows how to solve it?
If you want your TextView be over the toolbar, in this case, you can try to set higher elevation value to TextView. In some cases, it worked for me.
For example:
android:elevation="15dp"

CollapsingToolbar doesn't fully collapse

I have a Navigation Drawer Activity (NavActivity) in which one of the fragments (OuterFrag.xml) has a Collapsing Toolbar and a View Pager. When I scroll in the View Pager(InnerFrag.xml), the toolbar collapses, but not fully. Here's the image and the code before I go any further..
OuterFrag.xml
InnerFrag.xml
The problem has to be in OuterFrag, which contains the CollapsingToolbar. I've tried setting the height of the CollapsingToolbar to "1dp", but then a black Toolbar appears with the same size of the red are in the image above!
Found the solution!
I removed the android:fitsSystemWindows="true" from the CoordinatorLayout and the AppBarLayout and now, the Toolbar collapses completely!
If you are using CollapsingToolbarLayout inside a fragment which is inside a fullscreen activity, removing all the fitSystemWindows="true" will make it work.

How to set expandedTitleMarginBottom for CollapsingToolbarLayout programmatically

We have some hidden views inside CollapsingToolbarLayout. So when we are making those view visible alignment of title is changed. so we need to change the value of expandedTitleMarginBottom for adjusting alignment.
How can we set expandedTitleMarginBottom for CollapsingToolbarLayout programmatically ?
For anyone searching for this : you can call setExpandedTitleMarginBottom(int px) on the collapsibleToolbarLayout

Set NavigationDrawer's ListView margin programmatically

I am currently struggling to design my application the way i want to.
In my app i am using a NavigationDrawer and different fragments. By clicking on an item in the NavigationDrawer i swap out the fragment that is currently active.
There is one main fragment which shows a map and doesn't show a toolbar. When I switch to another fragment I want to show my toolbar and let the user interact with it.
Now when I show the toolbar I have to set the top margin of the NavigationDrawer to the size of the toolbar so it doesn't get overlapped.
When I am showing the toolbar I set the margin of the NavigationDrawer's listview like this:
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mDrawerListView.getLayoutParams();
params.setMargins(0, drawerMarginTop, 0, 0);
mDrawerListView.setLayoutParams(params);
mDrawerListView.requestLayout();
The outcome is like the complete opposite of what i expect. It seems like the margin is applied to the bottom of the view.
Screenshot:
Another thing that annoys me is that the toggle-arrow of the toolbar is not centered correctly. It's a little bit higher than it should be, so it overlaps the system bar in the top and doesn't fill the whole size of the toolbar. I tried to make this clear in the following picture:
If you need any xml or code just let me know and I will edit my question.
Thank you in advance!
EDIT 1+2:
My toolbar style:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar_navigation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/my_color"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
EDIT 3:
The Problem with the toggle-arrow not being centered is fixed now. Thanks to Alchete.
Unfortunately the NavigationDrawer is still buggy. I found out that if I open and close the NavigationDrawer many times it somehow changes its layout at one time and the margin is set correctly... Is there any way to force this top happen immediately?
After many times of opening and closing the drawer it looks like this: (Exactly what I want it to look like)
There must be a way to force this immediately, right?
Your alignment issue is most likely due to your toolbar height. You should be setting the toolbar height as follows:
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize">
Here's the same issue for reference: android.support.v7.widget.Toolbar icon alignment issue
I would also be using Google's IOSched app for reference on how to set these items up properly. You can find all the code on Github.
Here are their layout files. Scroll down to see their toolbar/navdrawer layouts: https://github.com/google/iosched/tree/dfaf8b83ad1b3e7c8d1af0b08d59caf4223e0b95/android/src/main/res/layout
And, also note that Google's reference design is to OVERLAP the toolbar with the navdrawer -- which is not how you have it. And, the right margin should be equivalent to the toolbar height.
See here: http://www.google.com/design/spec/patterns/navigation-drawer.html
I'm not 100% about this but it looks like you're setting the ViewGroup layout params to be of type MarginLayoutParams. Instead, set the margin on a 'normal' root ViewGroup type e.g. RelativeLayout and pass that to the View:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
params.setMargins(0, drawerMarginTop, 0, 0);
mDrawerListView.setLayoutParams(params);
mDrawerListView.requestLayout();
You may want to change MATCH_PARENT to WRAP_CONTENT depending on your xml.

Categories

Resources