Question about right alignment of sencha buttons

Source: Internet
Author: User

You may have tried

Docked: 'right'

Then the right side is not correct.

You may have tried

Right: '0%'

Top '123'

Ugly

You may have tried

Align: 'right'

Sorry, the button does not have this attribute.

So... The answer is:

 

 
Items: [{xtype: 'call', UI: 'mask', iconcls: 'refresh', Handler: refresh}, {xtype: 'spacer'}, {xtype: 'button ', UI: 'mask', iconcls: 'add', Handler: refresh}]

Add a space.

 

Just to explain the reason behind this. in sencha touch, toolbars are nothing more than containers with an hbox layout and custom styling. so in order to alter the alignment, the pack and other hbox layout configuration you coshould do:

Code:
 
Layout: {Pack: 'justify ', align: 'center' // align center is the default}

This also means that you can set the property "flex" on every item inside a toolbar to have them take up the remaining space.

Finally I Just Wanted To paste the code for the spacer class to show you what it does.

Code:
 
Ext. spacer = ext. Extend (ext. component, {initcomponent: function () {If (! This. width) {This. Flex = 1 ;}ext. spacer. superclass. initcomponent. Call (this );}});

As you can see you can give a spacer a fixed width, and if you dont do that it will use a flex of one. this means that if you use the following order of items in your Toolbar [Button, spacer, button, spacer, button], you will get a button on the left, one in the center and one on the right with the spacers both taking up an equal amount of space.

I hope this answered your question.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.