Skip to main content

Posts

Showing posts with the label IconButton

Jetpack Compose: IconButton from vector resource

Introduction In modern Android development, Jetpack Compose has become a popular toolkit for building user interfaces. It simplifies the UI development process by using a declarative approach, where developers describe how UI elements should look based on the app's state. One useful feature in Jetpack Compose is the ability to use vector resources for displaying icons. In this article, we will break down an Android Kotlin example that demonstrates how to create IconButton elements from vector resources using Jetpack Compose. This example showcases how to build a basic user interface with buttons containing icons from vector resources. When these buttons are clicked, they update a message on the screen. This project not only highlights the simplicity and flexibility of Jetpack Compose but also emphasizes how easily developers can integrate vector-based icons in their UI. Main Components of the Code The code begins with a typical setup for an Android activity using AppCompatActivity...

flutter - How to use IconButton onPressed

Flutter - IconButton onPressed The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to use IconButton onPressed property. The IconButton onPressed property makes the button clickable when the developers set a value to it. If they pass a null value to this onPressed property value the button act as disable/nonclickable. Actually, the onPressed property is used to trigger an action when someone clicks the IconButton widget. The IconButton class’s onPressed property value is a callback that is called when the button is tapp...

flutter - How to disable an IconButton

Flutter - IconButton Disable The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to disable an IconButton widget. Here we will also set a color for the IconButton widget’s disabled state. The IconButton class’s onPressed property value is a callback that is called when the button is tapped or otherwise activated. When the flutter developers set this property value to null, the button will be disabled. So in this flutter example code, we passed a null value for the IconButton onPressed property to disable the IconButton ...

flutter - IconButton remove splash

Flutter - IconButton Remove Splash The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to remove the splash from an IconButton widget. In this example code, we used the IconButon class’s splashColor property to remove the splash effect of an InconButton widget. Here we also change the icon button’s highlight color by using the IconButton class’s highlightColor property. The IconButton class’s splashColor property value is a Color that defines the primary color of the button when the button is in the down/pressed state. Th...

flutter - How to remove IconButton padding

Flutter - IconButton Remove Padding The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can be used in many other places as well. The flutter app developers can leave the onPressed callback null to disable an IconButton, then it will not react to touch. The following flutter app development tutorial will demonstrate how to remove the padding from an IconButton widget. In this example code, we used the IconButon class’s padding property to remove the padding of an InconButton widget. Here we also change the icon button’s splash radius by using the IconButton class’s splashRadius property. The IconButton class’s padding property defines the padding around the button's icon. The entire padded icon will react to input gestures. The padding p...

flutter - How to change IconButton size

Flutter IconButton Size The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can be used in many other places as well. The flutter app developers can leave the onPressed callback null to disable an IconButton, then it will not react to touch. The following flutter app development tutorial will demonstrate how to set or change the IconButton widget size. Here we used the IconButton class’s iconSize property to change an IconButton widget’s size. The flutter developers must not override the icon's size with its Icon.size parameter when creating an IconButton widget. Instead, the flutter developers have to use the IconButton class’s iconSize parameter to set the IconButton widget’s size. The IconButton class’s iconSize property value is ...

flutter - How to use IconButton

Flutter IconButton The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can be used in many other places as well. The flutter app developers can leave the onPressed callback null to disable an IconButton, then it will not react to touch. The IconButton class has several useful properties such as alignment, autofocus, color, disabledColor, focusColor, highlightColor, hoverColor, icon, iconSize, isSelected, onPressed, padding, selectedIcon, splashColor, style, and tooltip. The IconButton class’s alignment property defines how the icon is positioned within the IconButton. The color property defines the color to use for the icon inside the button if the icon is enabled. The icon property defines the icon to display inside the button. The ic...

jetpack compose - How to use IconButton

Jetpack Compose IconButton The Button is a primary component for mobile application development. Sometimes android application developers need to show only an icon inside a Button widget. Android jetpack compose library provides a built-in widget to render an icon button in an app user interface. Jetpack compose is a declarative way to render an app user interface in an android application without an XML-based layout. So, jetpack compose code is easily manageable and less error-prone. This android application development tutorial will demonstrate to us how we can render and use an IconButton inside a jetpack compose application. IconButton is a clickable icon that acts as a Button widget and it represents action. IconButton’s overall minimum touch size is 48 dp width and 48 dp height which meets accessibility guidelines. An IconButton is typically used inside an app bar as an action button and inside a navigation component. To render an IconButton we have to pass an onClick e...