I'm trying to do what's highlighted on the image, but no luck so far.
Any suggestions on how could I do this? This raises some questions regarding the elevation, which is the main problem.
The Toolbar is set up properly and the rest (white space) will be views that are also set up inside the AppBarLayout.
Related
I was trying find a ready solution for it but couldn't.
The idea is to make the expanded toolbar with big title and when the content is not fit on the screen make it scrollable. The scroll behaviour is like this:
Expanded toolbar should be disappeared under a regular fix toolbar (height = 56.dp). Regular fix toolbar zIndex should be higher than disappearing expanded toolbar. No Motion effect. The big title from the disappearing toolbar should start to appear in the collapsed toolbar center (See attached screenshots)
In the toolbar body I should be able to work with ConstaintLayout component.
Mentioning this because when I was trying my custom solutions I had issues with height calculations right after I use ConstraintLayout.
I would really appreciate everyone for help.
I want to achieve something like this on picture:
I want to have TabLayout(Left) 200DP, and Burger icon for Navigation Drawer(Right).
Problem is that AppBarLayout don't support Horizontal orientation property. Just vertical.
I would like to import toolbar and TabLayout on same view. I saw on some apps that it's possible.
I managed to get 200DP TabLayout. Other than that - nope. Tried to put all into CoordinatorLayout and overlay icon over the AppBarlayout. On designer that looks same like on picture that I posted. When I run it - I don't see that layout overlaying AppBarLayout. I assume that AppBarLayout is above it.
Anyone have idea about this?
How can we create a collapsing toolbar layout like Yahoo News Digest application ?
Have you tried adding app:behavior_overlapTop="50dp" to your scrolling view? (This is the default behavior. Code can be found here.)
Apparently, it should support that attribute to make the scrolling view overlap your app bar.
Start by implementing the square collapsing toolbar as you can find in many other guides and then set that parameter.
If that does not work, you could write your own Behavior I guess, inspiring from the one I linked you (which is the default AppBarLayout behavior that allow the coordinator layout to collapse the top part.
To make the image not square you need to use a semi-transparent image or edit it by code.
My question is how do I do make the ActionBar transparent (and also the status bar)?
I'm having trouble trying to make use of the AppBarLayout and Toolbars on Android to achieve that.
I need that because I want to create an application that has one main Activity that holds a DrawerLayout and many screens which are mostly fragments. Then, there is some screens where the ActionBar and StatusBar becomes transparent (while still having the hamburger button for the DrawerLayout).
I've tried changing the AppBarLayout and the Toolbar, but it looks weird... It looks like there are some weird margins on the ActionBar.
appBarLayout.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));
toolbar.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));
And here is the result:
And here is it before changing the color/changing it back:
Any ideas on how to achieve the transparency on the ActionBar when some fragments are attached to the main content of the main Activity?
If you want to take a look at the code, here is the repository: Sample Repo.
Okay...
I made a mistake here...
First, all you need to do is remove the paddings on the content_main.xml and set the elevation of the appBarLayout to 0 and the code will work. (You'd need to set it back to its original value if you need the shadows).
I updated the repo to fix that and it should be working now.
But, There is another way to solve this problem using a fragment with its own AppBarLayout/Toolbar and hiding and showing the MainActivity AppBarLayout when you're showing the Fragment inner one.
I'll create a branch in the same repository to show what I mean.
Please, answer/comment with better solutions/ideas if have them.
Repo here.
When you use the background android:background="?android:attr/selectableItemBackgroundBorderless" it gives a nice circle ripple background. At https://developer.android.com/training/material/animations.html it says that It will be drawn upon, and bounded by, the nearest parent of the view with a non-null background.
How do you get around this? I know there must be a way because while using the standard ActionBar, it worked fine. When I used the compat Toolbar, it didn't work anymore and gets cut off. If you take off the colored background from the toolbar it works fine, but I want a colored toolbar...Does anyone know how to use the Toolbar class and still have the rippled selector be unbounded?
As a note I am asking about this for the Toolbar, but I have a few other places where I also need to do the same thing (I use a pull up bar like Play Music has that needs have unbounded buttons as well). So while a work-around for the Toolbar would be nice, it would be nice to have a generic solution as well. Also note that I am NOT talking about the problem described in Ripple effect on Toolbar cut off. I am talking about the selector being cutoff at the bounds of the parent, not cutoff at the button's bounds.