Skip to main content

Component Styling

Library components can be styled using the update block in Jetpack Compose or with XML attributes in layouts. Both approaches can be combined.

SecureTextField (input fields)

Attributes and methods apply to all SecureTextField input components: SecurePanField, SecureExpiryField, SecureCvvField, and SecureFullNameField.

Styling methods

MethodParameterDescription
setHint(hint)StringSets placeholder text.
setTextColor(color)IntSets text color.
setHintColor(color)IntSets placeholder text color.
setTextSize(sp)FloatSets text size in sp.
setFontFamily(family)StringSets font family by name.
setTypeface(typeface)TypefaceSets font using Typeface instance.
setBackgroundColor(color)IntSets background color.
setBorderColor(color)IntSets border color in normal state.
setFocusedBorderColor(color)IntSets border color in focused state.
setBorderWidth(widthPx)IntSets border width in pixels.
setBorderWidthDp(widthDp)FloatSets border width in dp.
setCornerRadius(radiusPx)FloatSets corner radius in pixels.
setCornerRadiusDp(radiusDp)FloatSets corner radius in dp.
setErrorColor(color)IntSets error color (text and border).
setErrorTextSize(sp)FloatSets error text size in sp.
setPadding(horizontalPx, verticalPx)Int, IntSets internal padding in pixels.
setPaddingDp(horizontalDp, verticalDp)Float, FloatSets internal padding in dp.
showLabelBooleanShows label above field (true/false). Default true.
labelTextString?Custom label text. If null, default translated label is used.
setLabelColor(color)IntSets label color.
setLabelTextSize(sp)FloatSets label text size in sp.
Information

For most cases, we recommend using *Dp setter variants (setBorderWidthDp, setCornerRadiusDp, setPaddingDp). Inputs are in dp and pixel conversion is handled internally by the library. These API methods are annotated with @Dimension(unit = Dimension.DP) to make expected unit explicit.

field.setBorderWidthDp(2f)
field.setCornerRadiusDp(12f)

Compose example (update block)

SecurePanField(
state = panState,
modifier = Modifier.fillMaxWidth(),
update = {
setBackgroundColor(Color.parseColor("#FAFAFA"))
setBorderColor(Color.parseColor("#1976D2"))
setFocusedBorderColor(Color.parseColor("#0D47A1"))
setBorderWidthDp(2f)
setCornerRadiusDp(12f)
setTextColor(Color.parseColor("#212121"))
setHintColor(Color.parseColor("#9E9E9E"))
setTextSize(16f)
setErrorColor(Color.parseColor("#C62828"))
setPaddingDp(horizontalDp = 14f, verticalDp = 10f)
setFontFamily("sans-serif-medium")
showLabel = true
labelText = null // null = use default translation from session.translation
setLabelColor(Color.parseColor("#616161"))
setLabelTextSize(12f)
}
)

To hide the label:

update = {
showLabel = false
}

XML attributes

XML attributeFormatDescription
app:secureFieldHintstringPlaceholder text shown when field is empty.
app:secureFieldTextColorcolorText color.
app:secureFieldHintColorcolorPlaceholder text color.
app:secureFieldTextSizedimensionText size (for example 18sp).
app:secureFieldFontFamilystringFont family (for example "monospace", "sans-serif-medium").
app:secureFieldBackgroundColorcolorField background color.
app:secureFieldBorderColorcolorBorder color in normal state.
app:secureFieldBorderWidthdimensionBorder width (for example 2dp).
app:secureFieldCornerRadiusdimensionCorner radius (for example 12dp).
app:secureFieldFocusedBorderColorcolorBorder color in focused state.
app:secureFieldErrorColorcolorError text and border color in error state.
app:secureFieldErrorTextSizedimensionError text size.
app:secureFieldPaddingHorizontaldimensionHorizontal inner padding.
app:secureFieldPaddingVerticaldimensionVertical inner padding.
app:secureFieldLabelstringCustom label above field. If missing, default translated label is used.
app:secureFieldShowLabelbooleanShows label (true/false). Default true.
app:secureFieldLabelColorcolorLabel color.
app:secureFieldLabelTextSizedimensionLabel size (for example 12sp).

Border states

Field border changes automatically based on current state:

StateBorder colorPriority
ErrorerrorColorHighest
FocusedfocusedBorderColorMedium
NormalborderColorLowest

Styling multiple fields at once

Using extension function, you can apply common style in each update block:

fun SecureTextField.applyCommonStyle() {
setBackgroundColor(Color.parseColor("#FAFAFA"))
setBorderColor(Color.parseColor("#1976D2"))
setFocusedBorderColor(Color.parseColor("#0D47A1"))
setBorderWidthDp(2f)
setCornerRadiusDp(12f)
setTextColor(Color.parseColor("#212121"))
setTextSize(16f)
}

SecurePanField(
state = panState,
modifier = Modifier.fillMaxWidth(),
update = {
applyCommonStyle()
setFontFamily("sans-serif-medium") // PAN-specific
}
)
SecureExpiryField(
state = expiryState,
modifier = Modifier.fillMaxWidth(),
update = { applyCommonStyle() }
)
SecureCvvField(
state = cvvState,
modifier = Modifier.fillMaxWidth(),
update = {
applyCommonStyle()
setTypeface(Typeface.MONOSPACE) // CVV-specific
}
)
SecureFullNameField(
state = fullNameState,
modifier = Modifier.fillMaxWidth(),
update = {
applyCommonStyle()
setHint("First and last name") // payer name specific
}
)

Using android:background

For SecureField, standard android:background can also be used in XML:

<cz.comgate.sdk.SecurePanField
android:background="#E8F5E9"
... />

For clearer configuration, we recommend using app:secureFieldBackgroundColor, which is designed specifically for field background styling.

SecurePayButton (payment button)

Styling methods

MethodParameterDescription
setText(text)StringSets button text.
setButtonTextColor(color)IntSets text color (active state).
setButtonTextSize(sp)FloatSets text size in sp.
setButtonFontFamily(family)StringSets font family.
setButtonTypeface(typeface)TypefaceSets font using Typeface instance.
setButtonBackgroundColor(color)IntSets background color (active state).
setButtonBorderColor(color)IntSets border color.
setButtonBorderWidth(widthPx)IntSets border width in pixels.
setButtonBorderWidthDp(widthDp)FloatSets border width in dp.
setButtonCornerRadius(radiusPx)FloatSets corner radius in pixels.
setButtonCornerRadiusDp(radiusDp)FloatSets corner radius in dp.
setDisabledBackgroundColor(color)IntSets background color in disabled state.
setDisabledTextColor(color)IntSets text color in disabled state.
setButtonPadding(horizontalPx, verticalPx)Int, IntSets inner padding in pixels.
setButtonPaddingDp(horizontalDp, verticalDp)Float, FloatSets inner padding in dp.
setLoadingAnimationEnabled(enabled)BooleanEnables/disables shimmer sweep animation during payment processing. Default: true.
Information

For most cases, we recommend using *Dp setter variants (setButtonBorderWidthDp, setButtonCornerRadiusDp, setButtonPaddingDp). Inputs are in dp and conversion to pixels is handled internally.

Compose example (update block)

SecurePayButton(
session = session,
collector = collector,
onPaymentResult = { result -> /* ... */ },
paymentParamsProvider = { /* ... */ },
modifier = Modifier.fillMaxWidth(),
update = {
setText("Pay")
setButtonBackgroundColor(Color.parseColor("#1E88E5"))
setButtonTextColor(Color.WHITE)
setButtonCornerRadiusDp(12f)
setButtonBorderColor(Color.parseColor("#1565C0"))
setButtonBorderWidthDp(1f)
setDisabledBackgroundColor(Color.parseColor("#CFD8DC"))
setDisabledTextColor(Color.parseColor("#78909C"))
setButtonTextSize(16f)
setLoadingAnimationEnabled(true)
}
)

XML attributes

XML attributeFormatDescription
app:payButtonTextstringButton text (default: "Pay").
app:payButtonTextColorcolorText color in active state.
app:payButtonTextSizedimensionText size.
app:payButtonFontFamilystringFont family.
app:payButtonBackgroundColorcolorBackground color in active state.
app:payButtonBorderColorcolorBorder color.
app:payButtonBorderWidthdimensionBorder width.
app:payButtonCornerRadiusdimensionCorner radius.
app:payButtonDisabledBackgroundColorcolorBackground color in disabled state.
app:payButtonDisabledTextColorcolorText color in disabled state.
app:payButtonPaddingHorizontaldimensionHorizontal inner padding.
app:payButtonPaddingVerticaldimensionVertical inner padding.
app:payButtonLoadingAnimationbooleanEnables/disables shimmer sweep animation during processing. Default: true.

Automatic disabled state

If disabled state colors are not explicitly set (payButtonDisabledBackgroundColor, payButtonDisabledTextColor), button automatically computes muted variant from active colors by reducing alpha to 50 %.

Processing animation

After button press, a shimmer sweep animation is displayed over button content - a semi-transparent sparkling band continuously moving left to right. Button keeps full background color and original text, while animation indicates ongoing processing.

You can disable animation in update block or directly on state:

SecurePayButton(
// ...
update = {
setLoadingAnimationEnabled(false)
}
)

When animation is disabled, button remains in calm disabled appearance during processing without visual effect.

SecurePaymentStatusView (status banner)

Compose usage

In Compose, component is used through rememberPaymentStatusState(). Visual styling is not exposed directly in Compose API - component automatically applies colors (green/orange/red) by payment state. Message translation can be configured via translation on state:

val statusState = rememberPaymentStatusState()
statusState.translation = Translation.Czech

SecurePaymentStatusView(state = statusState)

// Show result:
statusState.showStatus(paymentResult)
// or:
statusState.showError("Custom error message")
// Hide:
statusState.clear()

XML attributes

XML attributeFormatDescription
app:statusViewTextstringInitial message text (optional).
app:statusViewTextColorcolorText color.
app:statusViewTextSizedimensionText size.
app:statusViewFontFamilystringFont family.
app:statusViewBackgroundColorcolorBanner background color.
app:statusViewBorderColorcolorBorder color.
app:statusViewBorderWidthdimensionBorder width.
app:statusViewCornerRadiusdimensionCorner radius.
app:statusViewPaddingHorizontaldimensionHorizontal inner padding.
app:statusViewPaddingVerticaldimensionVertical inner padding.

Styling methods

MethodParameterDescription
setTextColor(color)IntSets text color.
setTextSize(sp)FloatSets text size in sp.
setFontFamily(family)StringSets font family.
setTypeface(typeface)TypefaceSets font using Typeface instance.
setStatusBackgroundColor(color)IntSets background color.
setBorderColor(color)IntSets border color.
setBorderWidth(widthPx)IntSets border width in pixels.
setBorderWidthDp(widthDp)FloatSets border width in dp.
setCornerRadius(radiusPx)FloatSets corner radius in pixels.
setCornerRadiusDp(radiusDp)FloatSets corner radius in dp.
setStatusPadding(horizontalPx, verticalPx)Int, IntSets inner padding in pixels.
setStatusPaddingDp(horizontalDp, verticalDp)Float, FloatSets inner padding in dp.
Information

For most cases, we recommend using *Dp setter variants (setBorderWidthDp, setCornerRadiusDp, setStatusPaddingDp). Inputs are in dp and pixel conversion is handled internally by the library.

Tip

Component starts in GONE state (hidden). It appears automatically after showStatus() and hides after clear(). More details in Payment Results.