Skip to content Skip to sidebar Skip to footer

View.setbackgroundresource() Is Not Setting The Correct Background Resource

I am coding a 'set pin' fragment for the second time and it's not working. Everything works great until I use switch blocks and View.OnTouchListener. I am trying to change the butt

Solution 1:

I have spent 2 hours and am trying to find out why the setBackgroundResource() is not working. I added some modification on the shape and I noticed that the change only made on the dimensions except the Color. So I created a style to eliminate the Tinte I put the backgroundTint on @null and everything works correctly.

here is the style I added

<stylename="NotTintedButton"parent="Widget.AppCompat.Button.Colored"><itemname="backgroundTint">@null</item></style>

And all you have to do is apply this style on each buttons. for example :

 <Button        
            style="@style/NotTintedButton"
            android:id="@+id/pin8"
            android:layout_width="@dimen/button_1_width"
            android:layout_height="@dimen/button_1_height"
            android:layout_margin="@dimen/button_1_margin"
            android:background="@color/primary_dark"
            android:fontFamily="@font/slatebook"
            android:padding="0dp"
            android:text="8"
            android:textColor="@color/primary_light"
            android:textSize="22sp" />

Post a Comment for "View.setbackgroundresource() Is Not Setting The Correct Background Resource"