To add both image and text in android button you should use button property androiddrawableTop androiddrawableBottom androiddrawableLeft or androiddrawableRight. Please refer to the following code.

Bar And Qr Code Icons Smartphone Symbols With Scan Barcode Circle Flat Buttons With Icon Barcode Art Icon Coding
Below example will set the settings icon image at the top of the button text.

Android image button with icon and text. Screen density var density mainDisplayInfoDensity. When the displayresolution is big enough show the picture with text otherwise the image only Detect the device density in XamarinForms by using XamarinEssentials. Combining text image on a Button or ImageButton.
The property value is just a drawable object id exist in the android project. . You can just add property ContentLayout for your Button.
This moves my icon straight to the left of the button and I want both icon and text centered inside the button. With text and an icon using the Button class with the androiddrawableLeft attribute. Creating a custom background for Button We will first start with crating a custom background for our image button.
Create a custom image and use it as the icon in an ImageButton in AndroidThis video is part of a playlist available at. Ive try setting up the padding but this only allows to give a fixed value so it is not what I need. This can be set to start ICON_GRAVITY_START default at start of button end ICON_GRAVITY_END at end of button textStart ICON_GRAVITY_TEXT_START at start of centered text label or textEnd.
I originally tried a layout object defined as widgetbutton then put an imageview and a textview in it but after profiling that and the Button layout above I saved nearly 30 in measure time 50 in layout time and 15-20 in Draw time on my FramLayout and went. To create a custom image button with a text we will create a relative layout with a custom background. If you want to have two lines of text you can use n line feed character to divide text.
But I dont know how to do that. I would like to make a Button like that in Android. The result is.
Get Metrics var mainDisplayInfo DeviceDisplayMainDisplayInfo. This option works best unless you need some sort of crazy looking button layout like an image sandwhiched by two textviews. I need to have icontext aligned in the center.
Following is the pictorial representation of using Image Buttons in android applications. Inside the relative layout there will be an ImageView and a textView widget. .
In the similar way you can use drawableRight drawableTop drawableBottom properties to create buttons with image right top or bottom to the text. By default the ImageButton looks same as normal button and it performs an action when a user clicks or touches it but the only difference is we will add a custom image to the button instead of text. How to stop EditText from gaining focus at Activity startup in Android.