Titanium - Android button "native" behavior upon styling - appcelerator

I've created 2 buttons:
<Button title="TEST"></Button>
<Button title="TEST" backgroundColor="red"></Button>
The first is a really simple default button. And the second I just added a red background color. The result is this:
As you can see from the picture, just adding a different background color changes the button a lot from it's "native" appearance. What I would expect is that the button will remain the same, just with a red background.
The "styled" button is bigger (and as you can see I did not set up any dimensions).
The "styled" button corners are no longer round.
Most bothering - the "styled" button no longer has the android button ripple effect upon clicking.
Why is that? Can it be fixed?

The native button (AppCompatButton) is a bit more complex and is not using the backgroundColor to show the actual color. I think it is using a 9-patch in the background so if you set a backgroundColor it will remove that and you end up with the box and the color.
Try using the tintColor to change the background color or you can fake it using:
borderRadius
elevation
touchFeedback
touchFeedbackColor

Related

Prevent Push Button from taking on background color in Dark Mode?

Put a Push Button on a custom NSView that has a background color, and in Light Mode, the button background remains white (both buttons are Push style with the default Tint) — but switch to dark mode and now the button takes on the background behind it.
Note the button (top right in image) color on a View that does not have a background color set looks as expected.
Is there a way to make a Push Button behave the same way in Dark Mode and not take on the color of the NSView behind it?

Xcode UI Label not appearing after running the project

This is the UI appears in the simulator. It appears only when pressed.
This is the UI in Storyboard.
In fact, there were clickable layers on top of those labels, where User Interaction is enabled.
This then triggers the background color of the labels to turn into white.
It is not the labels are not rendered, it is just that text color, the background color of the label and the color of the view are all white.
NOTE: Apology for the question which lacks details.

How to set color for a button in Xcode7?

Hi Im new to Xcode7 and Swift2 and I am trying to change the color of the buttons I am adding to my storyboard. Is there a way to change the color of the button in Xcode7? All I see are options to change color of text and add background image to a button but no change button color.
A button has many parts / aspects, so what do you mean by the "button color"? You probably mean the button's background color. If you scroll down in the button's attributes inspector, you'll come to the background color. The reason it's so far down is that it's a View (UIView) property, not merely a button (UIButton) property.

Changing click behaviour

When a Button having Content / Text 'ClickMe' is clicked, 'ClickMe' text is automatically arranged to foreground of the button.
But when user clicks the button having image on its background, background image becomes invisible & the foreground of button looks fully white.
Can we see the image on foreground instead of white color.
Is there any chance to change the foreground effect of the button when user clicks on button?
My Code "Button Height="128" HorizontalAlignment="Left" Margin="307,138,0,0" Name="button2" VerticalAlignment="Top" Width="150" BorderThickness="1">
"Button.Background>
ImageBrush ImageSource="/WinApp;component/Icons/camerabtn.png" />
/Button.Background>
/Button>"
Thanks in advance to all.
To do this you need to change the style of the button.
Easiest way to do that is in Expression Blend.
See this answer:
Windows Phone 7 (WP7) Change a button's background color on click
As Mick suggests, it would help to see some code for what you're trying to do, however, it sounds like you may have a change in a value (such as margin) in the Normal and Pressed states of the button resulting in the behavior you are seeing.

How can I change the way NSButtonCell objects highlight when clicked?

I am using several NSButtonCell objects in an NSTableView. They are simple square buttons with custom images on them.
These buttons draw properly when they are not highlighted: all that is visible is the image, and the rest of the button rectangle is transparent. However, when I click on them, the entire button rectangle is highlighted, inverting the background in the parts that were transparent.
I would prefer to see the image drawn inverted, and the transparent parts remain transparent. How can this be done?
Try setting your cell's highlightsBy property to NSContentsCellMask. I think you'll have to do this in code (probably in awakeFromNib); I don't see a way to do it in IB alone.
You can do it in Interface Builder too. I use "Square Button" so the button alters between two images (so the image is not inverted at all).
Your buttons behaviour is probably set to "Momentary Light" or "Momentary Push In".
Set the Behaviour to "Momentary Change", and it should work.

Resources