The MAFTextView control extends the capabilities of the android.widget.TextView native control. MAF adds styling capabilities to the TextView UI component, and provides predefined size variations, such as small and normal labels.
// normal label MAFTextView nLabel = new MAFTextView(this); LinearLayout.LayoutParams nl_lps = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); nLabel.setLayoutParams(nl_lps); nLabel.setText("NORMAL"); nLabel.setFocusable(true); labelRow.addView(nLabel);
<com.sap.maf.uicontrols.view.MAFTextView android:id="@+id/maflabel" android:layout_width="wrap_content" android:layout_height="50dip" android:text="skinned label" />
The MAF skinning engine customizes the text views. To apply SAP style, set the custom style for background, foreground, shadow, font family, and font size in the XML file.
<Style TargetType="Label" Key="DefLabel" platform="android"> <Setter Property="Foreground" Value="#ff333333" /> <!-- text color --> <Setter Property="FontFamily" Value="sans_serif" /> <!-- font size --> <Setter Property="FontSize" Value="18" /> <!-- font style --> </Style>
MAFTextView sLabel = new MAFTextView(this, "SmallLabel");
<Style TargetType="Label" Key="LargeLabel" BasedOn="DefLabel" platform="android"> <Setter Property="FontSize" Value="22" /> <Setter Property="Foreground" Value="#ff333333" /> </Style>
MAFTextView Label = new MAFTextView(this, "LargeLabel");
Foreground | Control's text color. |
FontFamily | Control's font family. |
FontSize | Control's font size. |