Recently I was working on a sencha touch project where I need to use a nig round image in sencha touch button. We all now that we can use images inside button using iconCls and iconMask property. That will put small icons inside your button along with button rounded corners and background colors. But in my case we don’t need button background color or rounded border of button. We just need a round image with transparent background and user should be able to click on it. There are number of ways for doing it.
First we can use xtype : image and put image url to it. But sometimes tap event does not work over image. So this not an option. Other option is to use panel and put image as html inside and add tap evet to panel body. But that will be on complete panel body. So in case of round image if user tapped outside the image but inside a panel, tap event will be fired. So here is the third solution.
As we know that Ext.button extends the Ext.component so we can add html to component. So we can add image as html as follow.
{
After adding this image is added inside the button and but still have button background colors and rounded border. This you can remove by updating your sencha touch CSS. Find the following class in sencha touch CSS.
.x-button, .x-button.x-button-back:after, .x-button.x-button-forward:after, .x-toolbar .x-button, .x-toolbar .x-button.x-button-back:after, .x-toolbar .x-button.x-button-forward:after {
background-image: none;
background-color: #ccc;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #f2f2f2), color-stop(3%, #d9d9d9), color-stop(100%,#bfbfbf));
background-image: -webkit-linear-gradient(top, #f2f2f2,#d9d9d9 3%,#bfbfbf);
background-image: -moz-linear-gradient(top, #f2f2f2,#d9d9d9 3%,#bfbfbf);
background-image: -o-linear-gradient(top, #f2f2f2,#d9d9d9 3%,#bfbfbf);
background-image: linear-gradient(top, #f2f2f2,#d9d9d9 3%,#bfbfbf);
}