Mobile Tutorial: Using a Button Component with Different Styles (iOS and Android)
Buttons in FireMonkey Mobile Applications
Following are some examples of different styles with Button components available for you to use in different parts of the user interface of your mobile application:
- Buttons on the Form:
|iOS 6||iOS 7||Android|
- Buttons on the Navigation Bar (also known as Toolbar):
|iOS 6||iOS 7||Android|
Define the Look and Feel for a Button Component
After you place a new button on the FireMonkey Mobile Designer, you can specify some important properties for a selected component by using the Object Inspector.
Select a component (in this case, a button), and then browse and change the value of some properties as follows:
- Change the text displayed on the button surface by updating the value of the Text property.
- Change the value of the Position.X and Position.Y properties (or drag the component using your mouse.)
- Change the value of the Height and/or Width properties (or drag the edge of the component using your mouse.)
- Click the down-arrow in the StyleLookup property.
- To create a colored button, change the values of the Tint and IconTintColor properties. The latter property is available only for styled buttons with icons.
Using TintColor on Buttons
- TintColor specifies the button background color.
- IconTintColor specifies the color of the icon on styled buttons.
For the Android target platform, you can apply a tint to buttons of any style.
For the iOS target platform, FireMonkey provides buttons that correspond to the Apple Style Guide, and some buttons might not support the tint feature. For example, on iOS 6, the segmented buttons do not support the tint feature, but on iOS 7, these buttons have the TintColor property.
When you change a button's StyleLookup property, the Object Inspector automatically displays or hides the TintColor and IconTintColor properties as appropriate. The following image shows three TSpeedButtons on an Android app:
Create a Segmented Control Using Button Components
FireMonkey uses a SpeedButton component to define the Segmented Control, which gives users the ability to select one value from several options.
To define a Segmented Control, use the following steps:
- Place three TSpeedButton components from the Tool Palette. Place the TSpeedButton components next to each other using your mouse:
- Select the first component, and change its StyleLookup property to segmentedbuttonleft:
- Select the second component, and change its StyleLookup property to segmentedbuttonmiddle.
- Select the third component, and change its StyleLookup property to segmentedbuttonright. Now all three buttons look like a Segmented Control:
- Select each component, and change the Text property as you like:
- Click and drag these three buttons to select these components:
- Set the GroupName property to a unique name such as LocationSegments:
- To specify that one of these components is to appear as Pressed by default, set the IsPressed property for one component to True:
Create a Scope Bar on a Toolbar Component
You can define a Segmented Control on a toolbar; this is also known as a Scope Bar, a segmented control that can be used to control the scope of a search.
Use the same TSpeedButton controls as in the previous steps, but with the following values for the StyleLookup property:
- Mobile Tutorial: Creating a FireMonkey Mobile Application (iOS and Android)
- Mobile Tutorial: Using a Calendar Component to Pick a Date (iOS and Android)
- Android Mobile Application Development
- FMX.Mobile.Controls Sample (Object Pascal)