0 votes

Background color in Android xml

I have the following code fragment

XML Button

  <Button
            android:id="@+id/strBtnAssociateDevice"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/round_borderCustom"
            android:onClick="GoToConfirmationNumber"
            android:text="@string/activity_login_loginButton"
            android:layout_marginTop="45dp"
            />

The Android:background xml is

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="00dp" />
    <solid android:color="#ffffff" />
    <stroke
        android:width="1dip"
        android:color="@color/colorAccent"
        />

</shape>

where I use it to put it in a button in which it generates me

introducir la descripción de la imagen aquí

What I would like is to be able to leave the background of the button in full red,

1voto

diegoveloper Points 2227

The attribute solid indicates the background color of your shape in the code you show, you have it blank, assuming that @color/colorAccent is red then you could do it this way:

   <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="00dp" />
    <solid android:color="@color/colorAccent" />
    <stroke
        android:width="1dip"
        android:color="@color/colorAccent"
        />

</shape>

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X