### Version Catalog Implementation Example Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md If using version catalogs, you can define the artifact type explicitly for font dependencies. ```gradle implementation(libs.material.typeface) { artifact { type = "aar" } } ``` -------------------------------- ### IconicsButton with Text and Icon Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family This example shows an IconicsButton that displays both text and an icon. The icon is defined using the standard icon syntax within the text attribute. ```xml ``` -------------------------------- ### IconicsImageButton Usage Example Source: https://github.com/mikepenz/android-iconics/wiki/IconicsImageView-Family Integrate this snippet to create an image button that displays an icon. It supports customization of icon, color, and dimensions, similar to IconicsImageView. ```xml ``` -------------------------------- ### IconicsImageView Usage Example Source: https://github.com/mikepenz/android-iconics/wiki/IconicsImageView-Family Use this snippet to display an icon with customizable color and size within your layout. Ensure the Iconics library is properly configured. ```xml ``` -------------------------------- ### Animated Icons with IconicsAnimatedDrawable Source: https://context7.com/mikepenz/android-iconics/llms.txt Create animated icons using `IconicsAnimatedDrawable` and built-in processors like `SpinProcessor` and `BlinkAlphaProcessor`. Attach processors and call `animateIn(view)` to start animations. Animations can also be configured via XML attributes. ```kotlin // Spinning loading indicator val spinningIcon = IconicsDrawable(this, GoogleMaterial.Icon.gmd_refresh) .toAnimatedDrawable() .apply { sizeDp = 36 colorInt = Color.BLUE } .processor(SpinProcessor(direction = SpinProcessor.Direction.CLOCKWISE)) .processor(SpinProcessor.also { SpinProcessor.DEFAULT_DURATION = 1000L }) val runner = spinningIcon.animateIn(imageView) imageView.setImageDrawable(spinningIcon) // Blinking icon — combine processors val blinkIcon = IconicsDrawable(this, FontAwesome.Icon.faw_bell) .toAnimatedDrawable() .apply { sizeDp = 32; colorInt = Color.RED } .processors( BlinkAlphaProcessor(), SpinProcessor(direction = SpinProcessor.Direction.COUNTER_CLOCKWISE) ) blinkIcon.animateIn(notificationView) notificationView.setImageDrawable(blinkIcon) // XML-driven animations via app:iiv_animations attribute (in IconicsImageView) // app:iiv_animations="spin|blink_alpha|blink_scale" // Stop animation when view is detached runner.unset() // Extension function on View for convenience imageView.tryToEnableIconicsAnimation(spinningIcon) ``` -------------------------------- ### Configure IconicsCheckableTextView Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family Use this XML to define an IconicsCheckableTextView with custom icons and colors for its start, top, end, and bottom positions, including distinct styles for checked and unchecked states. ```xml ``` -------------------------------- ### Implement GenericFont and Register Icons Source: https://github.com/mikepenz/android-iconics/wiki/CustomFontAddonCreating Create a GenericFont by providing a font ID and the path to the font file. Then, register each icon with its unicode value and a name. Finally, register the created GenericFont with Iconics. ```java GenericFont gf2 = new GenericFont("gmf", "fonts/materialdrawerfont.ttf"); gf2.registerIcon("person", '\ue800'); gf2.registerIcon("up", '\ue801'); gf2.registerIcon("down", '\ue802'); Iconics.registerFont(gf2); ``` -------------------------------- ### Implement CustomFont with ITypeface Source: https://github.com/mikepenz/android-iconics/wiki/CustomFontAddonCreating This Java code demonstrates how to create a custom font by implementing the `ITypeface` interface. It defines the font file, icon mappings, and provides methods to retrieve the typeface and icon details. Use this when you need to integrate a custom icon font. ```java public class CustomFont implements ITypeface { //define the font file to use private static final String TTF_FILE = "fontello.ttf"; private static Typeface typeface = null; private static HashMap mChars; //return a icon by it's key @Override public IIcon getIcon(String key) { return Icon.valueOf(key); } //return all possible key unicode-character mappings @Override public HashMap getCharacters() { if (mChars == null) { HashMap aChars = new HashMap<>(); for (Icon v : Icon.values()) { aChars.put(v.name(), v.character); } mChars = aChars; } return mChars; } /** * The Mapping Prefix to identify this font (example: fon-android -> `fon` is the mappingPrefix) * must have a length of 3 * * @return mappingPrefix (length = 3) */ @Override public String getMappingPrefix() { return "fon"; } //return all possible icon names @Override public Collection getIcons() { Collection icons = new LinkedList<>(); for (Icon value : Icon.values()) { icons.add(value.name()); } return icons; } //implement all additional methods from the interface //... //return the font from the assets (you can take this method in most cases) @Override public Typeface getTypeface(Context context) { if (typeface == null) { try { typeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + TTF_FILE); } catch (Exception e) { return null; } } return typeface; } //implement the enum containing all possible icons. each icon name is like `fontId`_`iconNamE` --> `fon_test1` maps to the icon with the unicode char \ue800 public static enum Icon implements IIcon { //define all possible mappings here: fon_test1('\ue800'), fon_test2('\ue801'); //define all methods required by the IIcon interface, you can just copy and paste those char character; Icon(char character) { this.character = character; } public String getFormattedName() { return "{" + name() + "}"; } public char getCharacter() { return character; } public String getName() { return name(); } // remember the typeface so we can use it later private static ITypeface typeface; public ITypeface getTypeface() { if (typeface == null) { typeface = new CustomFont(); } return typeface; } } } ``` -------------------------------- ### Use Icons in Jetpack Compose Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Utilize the provided `Image` wrapper in Jetpack Compose to display icons. Apply color filters for theming. ```kotlin Image( GoogleMaterial.Icon.gmd_access_alarm, colorFilter = ColorFilter.tint(MaterialTheme.colors.primary), ) ``` -------------------------------- ### Initialize Android-Iconics Library Source: https://context7.com/mikepenz/android-iconics/llms.txt Explicitly initialize the Iconics library with the application context in your Application class's onCreate() method. This is only necessary if Jetpack Startup is disabled or no view-based APIs are invoked before initialization. ```kotlin class MyApplication : Application() { override fun onCreate() { super.onCreate() // Explicit init — only needed if Jetpack Startup is disabled or no view APIs are used first Iconics.init(applicationContext) } } ``` -------------------------------- ### Add Compose Support Dependency Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Include the experimental compose support by adding the specified dependency to your project's build.gradle file. Requires v5.2.0 or later. ```gradle implementation "com.mikepenz:iconics-compose:${latestAndroidIconicsRelease}" ``` -------------------------------- ### Basic IconicsDrawable Creation Source: https://context7.com/mikepenz/android-iconics/llms.txt Demonstrates creating an IconicsDrawable from an IIcon enum or a string key. Supports customization of color, size, and padding. Use for basic icon display in ImageViews. ```kotlin val icon1 = IconicsDrawable(context, FontAwesome.Icon.faw_android).apply { colorInt = Color.RED sizeDp = 48 paddingDp = 4 } imageView.setImageDrawable(icon1) ``` ```kotlin val icon2 = IconicsDrawable(context, "gmd-favorite").apply { colorInt = Color.parseColor("#FF4081") sizeDp = 24 } ``` -------------------------------- ### Include Font Typeface Dependencies Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Add dependencies for the specific icon font typefaces you wish to use in your project. Ensure you use compatible versions, especially with Kotlin. ```gradle implementation 'com.mikepenz:google-material-typeface:4.0.0.3-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:google-material-typeface-{outlined|rounded|sharp}:4.0.0.2-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:material-design-iconic-typeface:2.2.0.9-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:fontawesome-typeface:5.9.0.3-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:octicons-typeface:11.1.0.1-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:meteocons-typeface:1.1.0.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:community-material-typeface:7.0.96.1-kotlin@aar' // note 5.3.45.1 and newer alphabetically sorts, and merges in 3 sections ``` ```gradle implementation 'com.mikepenz:weather-icons-typeface:2.0.10.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:typeicons-typeface:2.0.7.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:entypo-typeface:1.0.0.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:devicon-typeface:2.0.0.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:ionicons-typeface:2.0.1.8-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:pixeden-7-stroke-typeface:1.2.0.6-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:material-design-icons-dx-typeface:5.0.1.3-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:phosphor-typeface:1.0.0.1-kotlin@aar' ``` ```gradle implementation 'com.mikepenz:simple-icons-typeface:17.0.0.3@aar' ``` -------------------------------- ### Use IconicsTextView and IconicsButton with Inline Icons Source: https://context7.com/mikepenz/android-iconics/llms.txt IconicsTextView and IconicsButton process `{prefix-icon-name}` syntax in text and support compound drawables on all sides using `app:iiv_*` attributes. Useful for displaying text with integrated icons or as buttons with icons. ```xml ``` ```xml ``` ```xml ``` -------------------------------- ### Create IconicsDrawable Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Instantiate an IconicsDrawable in Kotlin, specifying the context, the icon, and applying customizations like color and size. ```kotlin IconicsDrawable(this, FontAwesome.Icon.faw_android).apply { colorInt = Color.RED sizeDp = 24 } ``` -------------------------------- ### Implement ITypeface for Type-Safe Icons Source: https://context7.com/mikepenz/android-iconics/llms.txt Implement the ITypeface interface for a fully type-safe approach, defining icons within an enum. This requires a font resource and a mapping of icon names to characters. ```kotlin // Full type-safe approach: implement ITypeface object BrandFont : ITypeface { override val fontRes: Int = R.font.brandicons override val characters: Map by lazy { Icon.values().associate { it.name to it.character } } override val mappingPrefix: String = "bnd" override val fontName: String = "Brand Icons" override val version: String = "1.0.0" override val iconCount: Int = Icon.values().size override val icons: Collection = Icon.values().map { it.name } override val author: String = "MyCompany" override val url: String = "https://example.com" override val description: String = "Custom brand icon set" override val license: String = "Proprietary" override val licenseUrl: String = "" override fun getIcon(key: String): IIcon = Icon.valueOf(key) enum class Icon(override val character: Char) : IIcon { bnd_logo('\ue800'), bnd_badge('\ue801'), bnd_sparkle('\ue802'); override val typeface: ITypeface get() = BrandFont } } ``` ```kotlin // Register and use Iconics.registerFont(BrandFont) val drawable = IconicsDrawable(context, BrandFont.Icon.bnd_logo).apply { sizeDp = 32 } ``` -------------------------------- ### Apply Advanced Styling with IconicsBuilder Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Use Iconics.Builder to apply multiple styles to all icons or specific icons. Styles can include foreground color, background color, and relative size. Apply the builder to a target view. ```kotlin Iconics.Builder() .style(ForegroundColorSpan(Color.WHITE), BackgroundColorSpan(Color.BLACK), RelativeSizeSpan(2f)) .styleFor(FontAwesome.Icon.faw_adjust, BackgroundColorSpan(Color.RED)) .on(tv1) .build() ``` -------------------------------- ### State-Aware IconicsDrawable Source: https://context7.com/mikepenz/android-iconics/llms.txt Demonstrates creating a StateListDrawable with IconicsDrawables to provide different visual states, such as press feedback. Use when an icon needs to change appearance based on its state. ```kotlin val stateListDrawable = StateListDrawable().apply { addState(intArrayOf(android.R.attr.state_pressed), IconicsDrawable(context, FontAwesome.Icon.faw_thumbs_up).apply { sizeDp = 48; colorString = "#aaFF0000"; contourWidthDp = 1 }) addState(intArrayOf(), IconicsDrawable(context, FontAwesome.Icon.faw_thumbs_up).apply { sizeDp = 48; colorString = "#aa00FF00"; contourWidthDp = 2 }) } imageButton.setImageDrawable(stateListDrawable) ``` -------------------------------- ### Register GenericFont with Custom Icons Source: https://context7.com/mikepenz/android-iconics/llms.txt Use GenericFont for a quick approach to integrate custom icon fonts by mapping unicode characters to icon names. Ensure the .ttf font file is placed in the assets folder. ```kotlin class MyApplication : Application() { override fun onCreate() { super.onCreate() GenericFont("MyBrandFont", "Brand Icons", "bnd", "fonts/brandicons.ttf") .also { font -> font.registerIcon("logo", '\ue800') font.registerIcon("badge", '\ue801') font.registerIcon("sparkle", '\ue802') Iconics.registerFont(font) } } } ``` ```kotlin // Usage after registration val brandIcon = IconicsDrawable(context, "bnd-logo").apply { sizeDp = 48 colorInt = Color.BLUE } ``` -------------------------------- ### Gradle Dependencies for Android-Iconics Source: https://context7.com/mikepenz/android-iconics/llms.txt Add the core library, UI widgets, Jetpack Compose support, and desired font packs to your app's build.gradle file. Ensure to specify the artifact type for version catalog users. ```gradle dependencies { // Core library (required) implementation "com.mikepenz:iconics-core:5.5.0" implementation "androidx.appcompat:appcompat:1.6.1" // Optional: UI view widgets (IconicsImageView, IconicsTextView, IconicsButton, etc.) implementation "com.mikepenz:iconics-views:5.5.0" // Optional: Jetpack Compose support (since v5.2.0) implementation "com.mikepenz:iconics-compose:5.5.0" // Font packs — add only what you need implementation 'com.mikepenz:google-material-typeface:4.0.0.3-kotlin@aar' implementation 'com.mikepenz:fontawesome-typeface:5.9.0.3-kotlin@aar' implementation 'com.mikepenz:octicons-typeface:11.1.0.1-kotlin@aar' implementation 'com.mikepenz:community-material-typeface:7.0.96.1-kotlin@aar' implementation 'com.mikepenz:ionicons-typeface:2.0.1.8-kotlin@aar' implementation 'com.mikepenz:weather-icons-typeface:2.0.10.8-kotlin@aar' implementation 'com.mikepenz:phosphor-typeface:1.0.0.1-kotlin@aar' implementation 'com.mikepenz:simple-icons-typeface:17.0.0.3@aar' } // For version catalog users, add the artifact type manually: // implementation(libs.google.material.typeface) { artifact { type = "aar" } } ``` -------------------------------- ### Automatic XML Icon Processing with IconicsContextWrapper Source: https://context7.com/mikepenz/android-iconics/llms.txt Wrap the base Context to intercept layout inflation and automatically process icon syntax in TextView and Button attributes. This works without AppCompatActivity. ```kotlin // Option A: wrap the Context in attachBaseContext (works without AppCompatActivity) class MyActivity : Activity() { override fun attachBaseContext(newBase: Context) { super.attachBaseContext(IconicsContextWrapper.wrap(newBase)) } } // Extension function equivalent override fun attachBaseContext(newBase: Context) { super.attachBaseContext(newBase.wrapByIconics()) } ``` -------------------------------- ### Create IconicsDrawable with Enum and Custom Size/Padding Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Create an IconicsDrawable using the font's enum for the icon. Customize the size and padding using sizeDp and paddingDp properties. ```kotlin IconicsDrawable(this, FontAwesome.Icon.faw_adjust).apply { sizeDp = 24 paddingDp = 1 } ``` -------------------------------- ### Build Icon Arrays with IconicsArrayBuilder Source: https://context7.com/mikepenz/android-iconics/llms.txt Create an array of IconicsDrawable instances by cloning a base drawable and applying different icons. This is useful for populating adapters for ListView or RecyclerView. ```kotlin // Create a base template with shared styling val base = IconicsDrawable(this).apply { sizeDp = 48 colorInt = Color.GREEN backgroundColorInt = Color.DKGRAY paddingDp = 4 roundedCornersDp = 8f } // Build array — each entry clones the base and applies the given icon val icons: Array = IconicsArrayBuilder(base) .add(FontAwesomeBrand.Icon.fab_android) .add(Octicons.Icon.oct_octoface) .add(GoogleMaterial.Icon.gmd_favorite) .add(CommunityMaterial.Icon2.cmd_github) .build() // Use in an adapter listView.adapter = object : ArrayAdapter(this, 0, icons) { override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { val view = convertView ?: layoutInflater.inflate(R.layout.row_icon, parent, false) view.findViewById(android.R.id.icon).setImageDrawable(getItem(position)) return view } } // Extension shorthand val moreIcons = base.createArray { add(FontAwesome.Icon.faw_star) add(FontAwesome.Icon.faw_heart) add(FontAwesome.Icon.faw_home) } ``` -------------------------------- ### Wrap BaseContext with IconicsContextWrapper Source: https://github.com/mikepenz/android-iconics/blob/develop/MIGRATION.md An alternative method to enable Iconics features if not extending AppCompatActivity or implementing AppCompatDelegate. This involves wrapping the base context. ```java super.attachBaseContext(IconicsContextWrapper.wrap(newBase)); ``` -------------------------------- ### Iconics Checkable Widgets in XML Source: https://context7.com/mikepenz/android-iconics/llms.txt Use these XML layouts to integrate custom checkable widgets with icon fonts. Configure checked/unchecked states, colors, and sizes. ```xml ``` -------------------------------- ### Create IconicsDrawable with String Key Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Instantiate an IconicsDrawable using a string key for the icon. The actionBar() method can be called to apply default action bar styling. ```kotlin IconicsDrawable(this, "faw-adjust").actionBar() ``` -------------------------------- ### Inject Icons into Menu XML with IconicsMenuInflaterUtil Source: https://context7.com/mikepenz/android-iconics/llms.txt Use IconicsMenuInflaterUtil to parse and apply icon attributes defined in menu XML resources to menu items. This utility also supports BottomNavigationView. ```xml ``` ```kotlin // In Activity.onCreateOptionsMenu override fun onCreateOptionsMenu(menu: Menu): Boolean { // Inflate and automatically apply all iconics attributes from XML IconicsMenuInflaterUtil.inflate(menuInflater, this, R.menu.menu_main, menu) return true } // Extension function alternative override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflateWithIconics(this, R.menu.menu_main, menu) return true } // For BottomNavigationView — only parse, do not re-inflate binding.bottomNav.menu.parseXmlAndSetIconicsDrawables(this, R.menu.menu_navigation) // Manual icon assignment (without XML attributes) menu.findItem(R.id.action_home).icon = IconicsDrawable(this, CommunityMaterial.Icon2.cmd_home).apply { sizeDp = 24 colorInt = Color.WHITE } ``` -------------------------------- ### IconicsTextView with Default Icon Override Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family Demonstrates overriding a default icon for the 'all' side with a specific icon for the 'bottom' side. This allows for fine-grained control over icon display. ```xml ``` -------------------------------- ### Add Views Dependency (Optional) Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Optionally, add the dependency for UI view widgets like IconicsButton and IconicsImageView if you plan to use them in your layouts. ```gradle //this adds all ui view widgets (IconicsButton, IconicsImageView, ...) implementation "com.mikepenz:iconics-views:${latestAndroidIconicsRelease}" ``` -------------------------------- ### IconicsTextView with Text and Icons Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family Use this snippet to display text along with inline icons within an IconicsTextView. Icons are defined using curly braces and font-awesomelike syntax. ```xml ``` -------------------------------- ### IconicsTextView with Side Drawables Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family Configure an IconicsTextView to display icons on all sides using app:iiv_all_icon, app:iiv_all_color, and app:iiv_all_size attributes. This is useful for adding consistent visual elements. ```xml ``` -------------------------------- ### Jetpack Compose Image Composable Source: https://context7.com/mikepenz/android-iconics/llms.txt Integrate icon fonts directly into your Compose UI using the `Image` composable. Customize size, color, and apply contour effects via `IconicsConfig`. ```kotlin import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.compose.IconicsConfig @Composable fun IconShowcase() { Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { // Minimal usage — 24dp default size Image( asset = GoogleMaterial.Icon.gmd_access_alarm, colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.primary) ) // Custom size Image( asset = FontAwesome.Icon.faw_heart, modifier = Modifier.size(48.dp), colorFilter = ColorFilter.tint(Color.Red) ) // Custom paint and contour via IconicsConfig Image( asset = CommunityMaterial.Icon2.cmd_github, modifier = Modifier.size(36.dp), iconicsConfig = IconicsConfig( iconBrush = SolidColor(Color.Black), contourBrush = SolidColor(Color.Gray), paddingDp = 2 ) ) } } ``` -------------------------------- ### Use IconicsImageView Widget Source: https://context7.com/mikepenz/android-iconics/llms.txt Replace standard ImageView with IconicsImageView for direct icon referencing in XML via `app:iiv_icon`. Supports programmatic updates to the icon and its properties. ```xml ``` ```kotlin val iconView = findViewById(R.id.my_icon) iconView.icon = IconicsDrawable(this, GoogleMaterial.Icon.gmd_star).apply { colorInt = Color.YELLOW sizeDp = 36 } ``` -------------------------------- ### IconicsButton with Side Drawables Source: https://github.com/mikepenz/android-iconics/wiki/IconicsTextView-Family Use this snippet to create an IconicsButton with icons displayed on all sides. Attributes like app:iiv_all_icon, app:iiv_all_color, and app:iiv_all_size control the icon's appearance. ```xml ``` -------------------------------- ### Use Icons in Text via XML Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Embed icons directly within text strings using the {fontId-iconName} syntax. Ensure the font and icon are available in the library. ```gson Some great text with a {faw-android} font awesome icon and {met-wind} meteocons icons. ``` -------------------------------- ### Use Custom GenericFont Icon Source: https://github.com/mikepenz/android-iconics/wiki/CustomFontAddonCreating After defining and registering a GenericFont, you can use its icons within your application by referencing the font ID and icon name. ```java new IconicsDrawable(this).icon("gmf-person").sizeDp(24); ``` -------------------------------- ### Drawable XML for Icons (API 24+) Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Define icons as drawables in your XML layout for API 24 and above. Supports custom theming attributes for color, contour, and size. ```xml // all custom theming attributes supported ``` -------------------------------- ### Advanced IconicsDrawable Styling Source: https://context7.com/mikepenz/android-iconics/llms.txt Shows how to apply advanced styling to an IconicsDrawable, including contour, background, shadow, and rounded corners. Suitable for complex icon designs. ```kotlin val richIcon = IconicsDrawable(context, CommunityMaterial.Icon2.cmd_heart).apply { colorInt = Color.WHITE sizeDp = 56 paddingDp = 8 contourWidthDp = 2 contourColorInt = Color.RED backgroundColorInt = Color.DKGRAY roundedCornersDp = 12f applyShadow { shadowRadiusPx = 8f shadowDxPx = 2f shadowDyPx = 2f shadowColorInt = Color.BLACK } } ``` -------------------------------- ### IconicsDrawable Action Bar Preset Source: https://context7.com/mikepenz/android-iconics/llms.txt Applies a predefined preset for action bar or toolbar icon sizes and padding. Use for consistent icon sizing in app bars. ```kotlin // Action bar / toolbar size preset drawable.actionBar() // sets size=24dp, padding=2dp ``` -------------------------------- ### Copy IconicsDrawable with Modifications Source: https://context7.com/mikepenz/android-iconics/llms.txt Shows how to create a modified copy of an existing IconicsDrawable. Useful for reusing a base style while changing specific attributes like color or size. ```kotlin val copy = richIcon.copy(colorList = ColorStateList.valueOf(Color.BLUE), sizeDp = 32) ``` -------------------------------- ### Automatic XML Icon Processing with IconicsLayoutInflater Source: https://context7.com/mikepenz/android-iconics/llms.txt Set the layout inflater factory in onCreate to automatically process icon syntax in TextView and Button attributes. This is the preferred method when using AppCompatActivity. ```kotlin // Option B: set layout inflater factory in onCreate (preferred with AppCompatActivity) class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { layoutInflater.setIconicsFactory(delegate) super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // All TextViews and Buttons in activity_main.xml now render {prefix-name} icons automatically } } // With LayoutInflaterCompat directly (advanced) override fun onCreate(savedInstanceState: Bundle?) { LayoutInflaterCompat.setFactory2( layoutInflater, IconicsLayoutInflater2(delegate) ) super.onCreate(savedInstanceState) } ``` -------------------------------- ### Register Custom Font in Application Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Register custom fonts by extending the Application class and calling Iconics.registerFont() in the onCreate method. This should be done before using the custom font. ```kotlin class CustomApplication : Application() { override fun onCreate() { super.onCreate() //register custom fonts like this (or also provide a font definition file) Iconics.registerFont(CustomFont()) } } ``` -------------------------------- ### IconicsDrawable Extension Properties for Styling Source: https://context7.com/mikepenz/android-iconics/llms.txt Utilizes Kotlin extension properties for convenient setting of various visual attributes like size, padding, color, contour, background, and shadow. Supports dp/sp units and typed setters. ```kotlin import com.mikepenz.iconics.utils.* val drawable = IconicsDrawable(context, FontAwesome.Icon.faw_star).apply { sizeDp = 32 // uniform size in dp sizeX = IconicsSize.dp(40) // width only sizeY = IconicsSize.dp(30) // height only paddingDp = 4 colorInt = Color.YELLOW colorString = "#FF9800" // hex string contourColorInt = Color.BLACK contourWidthDp = 1 backgroundColorInt = Color.LTGRAY backgroundContourColorInt = Color.GRAY roundedCornersDp = 6f iconOffsetXDp = 2 iconOffsetYDp = -1 shadowRadius = IconicsSize.dp(4) shadowDx = IconicsSize.dp(1) shadowDy = IconicsSize.dp(1) shadowColor = IconicsColor.colorInt(Color.argb(128, 0, 0, 0)) autoMirroredCompat = true // auto-flip for RTL layouts } ``` -------------------------------- ### Add Core Library Dependency Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Include the core Android-Iconics library in your project's build.gradle file. This is the essential dependency for using the library's features. ```gradle dependencies { //the core iconics library (without any widgets) implementation "com.mikepenz:iconics-core:${latestAndroidIconicsRelease}" implementation "androidx.appcompat:appcompat:${versions.appCompat}" } ``` -------------------------------- ### Style Icons in TextView/Button with Iconics.Builder Source: https://context7.com/mikepenz/android-iconics/llms.txt Use Iconics.Builder to replace icon placeholders in TextViews or Buttons with styled glyphs. Apply global styles or specific styles to individual icons. Can be applied directly to a TextView/Button or return a Spanned object. ```kotlin Iconics.Builder() .style( ForegroundColorSpan(Color.WHITE), BackgroundColorSpan(Color.BLACK), RelativeSizeSpan(1.5f) ) .styleFor( FontAwesome.Icon.faw_adjust, // target specific icon BackgroundColorSpan(Color.RED), ForegroundColorSpan(Color.YELLOW) ) .on(myTextView) // myTextView.text contains "{faw-adjust} Settings {gmd-home} Home" .build() ``` ```kotlin val styled: Spanned = Iconics.Builder() .style(ForegroundColorSpan(Color.BLUE)) .on("Tap {faw-heart} to like or {gmd-share} to share") .build() myTextView.text = styled ``` ```kotlin val spanned = "Download {gmd-file_download} now".buildIconics { style(ForegroundColorSpan(Color.GREEN), RelativeSizeSpan(1.2f)) } ``` ```kotlin myButton.buildIconics { style(BackgroundColorSpan(Color.DKGRAY), ForegroundColorSpan(Color.WHITE)) } ``` -------------------------------- ### IconicsButton Custom View Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Use IconicsButton to display icons alongside text in buttons. Icons can be prepended to the button's text. ```xml ``` -------------------------------- ### IconicsCheckBox XML Usage Source: https://github.com/mikepenz/android-iconics/wiki/IconicsCompoundButton-Family Use this XML to configure an IconicsCheckBox with custom icons, colors, and sizes for both checked and unchecked states. Ensure the necessary namespace is declared. ```xml ``` -------------------------------- ### Convert IconicsDrawable to Bitmap Source: https://context7.com/mikepenz/android-iconics/llms.txt Illustrates converting an IconicsDrawable to a Bitmap, useful for displaying icons in notifications or widgets where a Drawable is not directly supported. ```kotlin val bitmap = IconicsDrawable(context, GoogleMaterial.Icon.gmd_notifications).apply { sizeDp = 24 colorInt = Color.WHITE }.toBitmap() ``` -------------------------------- ### Add Cmap Table to Truetype Font Source: https://github.com/mikepenz/android-iconics/blob/develop/DEV/font-modifying-mac/info.txt Use this command to add a cmap table back to a Truetype font file after modifications. Ensure the font file is correctly prepared. ```bash ftxdumperfuser -t cmap -A f MaterialIcons-Regular.ttf ``` -------------------------------- ### Convert IconicsDrawable to Animated Drawable Source: https://context7.com/mikepenz/android-iconics/llms.txt Transforms an IconicsDrawable into an animated drawable. Use when an icon needs to support animation. ```kotlin // Convert to animated drawable val animated = drawable.toAnimatedDrawable() ``` -------------------------------- ### IconicsTextView Custom View Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Integrate icons within TextViews using IconicsTextView. Icons can be embedded directly in the text content. ```xml ``` -------------------------------- ### Render IconicsDrawable to Bitmap Source: https://context7.com/mikepenz/android-iconics/llms.txt Converts an IconicsDrawable to a Bitmap, suitable for use in widgets, notifications, or other contexts where a Bitmap is required instead of a Drawable. ```kotlin // Render to Bitmap for non-View usage (widgets, notifications) val bmp = drawable.toBitmap() ``` -------------------------------- ### Register Custom Font with Android-Iconics Source: https://context7.com/mikepenz/android-iconics/llms.txt Register a custom font by implementing the ITypeface interface or by using the GenericFont class for .ttf assets with manual unicode mapping. This should be done in your Application class's onCreate() method before using icons from the custom font. ```kotlin // Register a fully implemented custom font (implements ITypeface) class MyApplication : Application() { override fun onCreate() { super.onCreate() // Register a type-safe custom font class Iconics.registerFont(CustomFont) // Register a generic font from a .ttf asset with manual unicode mapping GenericFont("MyFont", "My Display Name", "mfn", "font/myfont.ttf") .also { gf -> gf.registerIcon("home", '\ue800') gf.registerIcon("search", '\ue801') gf.registerIcon("close", '\ue802') Iconics.registerFont(gf) } } } ``` -------------------------------- ### Define XML Drawable with IconicsDrawable Source: https://context7.com/mikepenz/android-iconics/llms.txt Define an IconicsDrawable in XML for use as a standard drawable resource. Supports various styling attributes like icon, color, size, padding, contour, background, corner radius, and shadow. ```xml ``` ```xml ``` -------------------------------- ### Dump Cmap Table from Truetype Font Source: https://github.com/mikepenz/android-iconics/blob/develop/DEV/font-modifying-mac/info.txt Use this command to extract the cmap table from a Truetype font file. This is useful for inspecting character mappings. ```bash ftxdumperfuser -t cmap -A d MaterialIcons-Regular.ttf ``` -------------------------------- ### IconicsImageView Custom View Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md Use IconicsImageView for displaying icons in custom views. Supports various attributes for color, size, padding, contour, background, and shadows. ```xml // or @string/gmd_favorite with our generator //app:iiv_size="12dp" //app:iiv_padding="2dp" //app:iiv_contour_color="#FF0000" //app:iiv_contour_width="2dp" //app:iiv_background_color="#FFFF00" //app:iiv_corner_radius="2dp" //app:iiv_background_contour_color="#FF0000" //app:iiv_background_contour_width="1dp" //app:iiv_shadow_radius="4dp" //app:iiv_shadow_dx="1dp" //app:iiv_shadow_dy="1dp" //app:iiv_animations="spin|blink_alpha|blink_scale" ``` -------------------------------- ### Batch Update IconicsDrawable Properties Source: https://context7.com/mikepenz/android-iconics/llms.txt Applies multiple property updates to an IconicsDrawable efficiently, invalidating the drawable only once at the end. Useful for sequential styling changes. ```kotlin // Efficient batch update — invalidates only once at the end drawable.apply { colorInt = Color.RED paddingDp = 8 sizeDp = 64 } ``` -------------------------------- ### Set IconicsLayoutInflater as Default LayoutInflater Source: https://github.com/mikepenz/android-iconics/blob/develop/MIGRATION.md Define the IconicsLayoutInflater as the default LayoutInflater to enable Iconics features on Android base views like ImageViews and TextViews. This requires an Activity extending AppCompatActivity or implementing AppCompatDelegate. ```java LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); ``` -------------------------------- ### Disable EmojiCompat in XML Source: https://github.com/mikepenz/android-iconics/blob/develop/README.md To resolve conflicts with AppCompat v1.4.x's default emoji support, disable emojiCompatEnabled in your XML layout. ```xml app:emojiCompatEnabled="false" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.