New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-26068] Android: Improve Ti.UI.Toolbar default behavior #9367
Conversation
Set a default aboslute content inset.
toolbar.addView(convertLayoutParamsForView(proxies[i].getOrCreateView())); | ||
View tempView = convertLayoutParamsForView(proxies[i].getOrCreateView()); | ||
Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
lp.gravity = Gravity.CENTER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to expose this as a property in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, my tests should pass now. Approved!
P.S.: @garymathews may now if there is a more sexy way of setting the default-width to fill, but this should work.
@@ -63,6 +66,7 @@ | |||
public TiToolbar(TiViewProxy proxy) { | |||
super(proxy); | |||
toolbar = new Toolbar(proxy.getActivity()); | |||
toolbar.setContentInsetsAbsolute(0,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after comma
@garymathews, @jquick-axway We have been talking with @hansemannn whether we should by default have the children be centered in the Toolbar or start from the beginning. As far as I tested Toolbar does not respect it's children's position attributes and acts solely as a container on native Android as well. So the proposition to have a property for begin\center gravity makes sense to me. And for further customization we can have setCustomView implemented. |
@ypbnv, regarding the toolbar's child view layout positions/attributes being ignored, try this. Add our Java The only down side here is that our horizontal |
Please note that iOS does not respect the margins / general styles as well, so Android probably should do the same there. It's simply because we want to follow the native behavior there - if people want to size the child-items, they would rather go with a manual horizontal layout which lays out the child-views in line. For now, I'd only change the width to Ti.UI.FILL by default and leave the native behavior as it is. But as @ypbnv said, maybe you as native Android devs see this different, I can only speak as a Titanium developer / end-user who would be fine and happy seeing the native behavior. |
@jquick-axway That will do the trick, yes. And it is the reason I thought about setCustomView() implementation. With it we will have the option to use any view (TiCompositeLayout) and get advantage of it, but not forcing it whenever it is not actually needed. |
Clean whitespaces from docs.
@ypbnv, Android typically left-aligns the Toolbar's content, right? And likely right-aligns for Arabic locales. I don't know if centering it is a good idea since that's not the native behavior. Now, defaulting the Toolbar's width to Ti.UI.FILL does make sense to me. We do the same for other views such as TableView, ListView, ScrollView, etc. We don't document that they're filled by default, but I think most devs expect this to be the default behavior anyways. |
Generated by 🚫 dangerJS |
I have updated the linked ticket. |
JIRA: https://jira.appcelerator.org/browse/TIMOB-26068
Description:
Set a default Ti.UI.FILL width for the toolbar.
Center content.
Test case: