Align Toolbar title and SearchView with list content with avatars - android

I'm trying to follow the material guidelines and I aligned the Toolbar title with the avatar like the image below following the instructions of #ChrisBanes in this answer.
My issue now is that when the SearchView is activated, it's not aligned anymore as seen in the second image. (It was aligned before changing the inset)
Any ideas of how I can align both things instead of having to choose between one or the other?

If you want to align avatar with search-view then you need remove space of homeup button and search-view.
FYI: search view behavior is different in large size device so you can go with custom action-bar.

I solved it by using app:titleMarginStart="16dp" instead of changing the contentInset. I have tested it only in a xhdpi phone, though.

Related

Popup options menu horizontal not appearing in center

i wanted to create a popup action menu for this fab.i used the quick action GitHub library but this is not coming centrally aligned.how to align it centrally.
https://github.com/piruin/quickaction
You must first import the library into your project.
https://github.com/piruin/quickaction/blob/master/quickaction/src/main/res/layout/quick_action_horizontal.xml
if you set the width value of HorizontalScrollView here to match_parent, you get the look you want. If you also leave a space around the edges (android: layout_marginHorizontal = "40dp") the design you want will appear. Of course, apart from what I wrote, you should adjust your own corrections.

Preview full XML from ScrollView without the telephone frame in Android Studio

I am wondering how can i preview my XML, without the telephone frame and see all the activity/fragment.
Why i want to do that? Because i'm using lots of ScrollViews and sometimes is impossible to see what's after the bottom of the telephone.
Is there any way to accomplish that?
First, You can set scrollview on top layout of xml and click on design tab.
Now see the first button of the above toolbar, press it and u can see full view of all layouts in xml.
For Example see below image:
In the toolbar above the preview pane, click on the settings icon (cogwheel) and deselect "Include Device Frame (if available)"

The buttons on Google play cards (CardView & RecycleView)

I've just started working on CardView and RecycleView and I want to know what are the side buttons that looks like 3 dots on every card and how to implement it.
Cards like we see in Google Play Store app, where there are cards with buttons.
I don't have enough reputation to post a picture but I'm posting this link where you can see it and the buttons are marked in red circle.
I don't think adding a toolbar on every card is a good idea (as suggested in another answer). As you can see in the image itself, there is no space for a full-width toolbar due to images taking up width of layout. So the best way will be to implement it using an ImageButton. Just add an imageButton on top and configure it to open a drop down menu or dialog or whatever.
P.S. Yes, there can be multiple toolbars according to new material design guidelines but having one on every card is probably not a good idea. Especially when it can't even be a full-width component.
You are looking for Toolbar.
It's a new Android Pattern to generalize ActionBar to use in multiple enviroments, like Cards and others.
How to use it: http://android-developers.blogspot.com.es/2014/10/appcompat-v21-material-design-for-pre.html

Gmail tablet style scroll bars with transparent actionbar

I've been trying stuff and searching for the last couple of hours and got no where so I thought I'd ask here.
Basically the Honeycomb version of Gmail has a listview on the right for it's message list and when you scroll the listview the items go under the actionbar which appears to have some form of gradient on it with #00FFFFFF at the bottom going up to #FFFFFFFF at the top giving the impression of the items fading out.
But they important thing to notice here is that the SCROLLBAR on the listview never goes underneath the ActionBar! and the default top position for the listview is underneath the scrollbar.
I've tried to implement a similar style layout for my app with a scrollview that scrolls underneath the actionbar which has an alpha set on it, it looks all nice and well but the scrollbars go underneath as well! :( and it makes it look a bit weird, it's not a nice option.
I've achieved what I have so far by using
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
and
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
which is a an XML drawable that simply has a color of #BB000000 (no gradient just yet)
this is the current effect, the scrollbar can be seen underneath the actionbar :(
this is the desired effect with the scrollbar never going into the actionbar but the content does scroll up underneath it
Edit: I think this probably uses something custom in Google and have all but given up figuring it out
call this before super.onCreate(savedInstanceState); in onCreate of your activity
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
More: http://developer.android.com/reference/android/view/Window.html#FEATURE_ACTION_BAR_OVERLAY
I can't see an easy way of doing this but I have come up with two possible solutions. There could well be a much better option that I couldn't see obviously.
The first and easiest, is to create a 9patch background file for you ActionBar that has an expanding gradient area and a fixed opaque area at the right hand side, the same side as your scroll bar. This way the scrollbar would still go under the ActionBar, but it would be hidden. However it would have the affect of the scrollbar disappearing / getting smaller.
Another option would be to edit the scrollbar thumb in the xml like this:
<ListView android:scrollbarThumbVertical="#drawable/YOUR_CUSTOM_THUMB" ></ListView>
Then create a scrollbar thumb with a transparent offset at the top.
Thinking about it I think the second option is probably the best to go for and will give you the best result. I realise it's a pretty crappy hack. Looking into a code way of doing it, I think you would have to extend a number of classes and override a load of methods.
simply use:
getActionBar().setBackgroundDrawable(null);

Android title buttons

I am trying to reproduce the account chooser widget that the GMail app has on top right.
I know already how to put things in the title but i have several problems:
I've tried putting a normal button in the title but it doesn't fit
It looks like the size of the title is bigger than what it is, for example if I put a normal button there, there is no way of making it the proper height, in fact goes below the app like if half of the title space was hidden below
I thought it might be a clickable label with a rectangular shape, but I tried it and no way to make it work.
Any hint?
Looking at the layout using the hierarchy viewer it seems like it really is just a Button inside a LinearLayout. The only interesting part is that the LinearLayout's layout_height is set to MATCH_PARENT (which is just the newer version of FILL_PARENT) where its parent the RelativeLayout has a hardcoded layout_height of 54.
I'm not sure if this is of help for you but maybe it can point you in the right direction.

Categories

Resources