xamarin android c#

Ibrar Tariq 20 Reputation points
2024-02-17T20:24:17.1933333+00:00

Xamarin Android C# using visual studio 2022 I am trying to create button with image and text but image is not showing.

 <Button
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:minWidth="500px"
     android:minHeight="250px"
     android:id="@+id/button1"
     android:text="button"
     android:background="@drawable/abc_ab_share_pack_mtrl_alpha"
     android:drawableLeft="@drawable/picture1"/>

I had already tried this link

http://cheahengsoon.weebly.com/blog/button-style-in-xamarinandroid

please solve my problem thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,377 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,341 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ahamed Musthafa Careem 461 Reputation points
    2024-02-18T10:31:00.6333333+00:00

    @Ibrar Tariq , In Xamarin.Android, to create a Button with both an image and text, you can use a combination of android:drawableLeft or android:drawableStart (depending on the layout direction) and android:text attributes. Here's how you can modify your XML layout to achieve this:

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minWidth="500px"
        android:minHeight="250px"
        android:text="Button Text"
        android:drawableStart="@drawable/picture1"
        android:drawableLeft="@drawable/picture1"     	   
    android:background="@drawable/abc_ab_share_pack_mtrl_alpha"/> 
    
    

    Hope this helps! Let me know if you have any further questions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.