Home > Blockchain >  cornerRadius not working with backgroungTint
cornerRadius not working with backgroungTint

Time:03-05

I am a beginner in android dev. I am making a calculator in which i want to add round button using corner Radius. the problem is that it is working fine when i donot set background tint as shown below

<Button
    android:id="@ id/button_7"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:text="7"
    android:textColor="#000000"
    app:cornerRadius="20dp" /> 

image

but when i set background tint it does not work

<Button
    android:id="@ id/button_7"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:text="7"
    android:textColor="#000000"
    app:cornerRadius="20dp"
    android:background="#E3E3E3"
    app:backgroundTint="#E3E3E3"/>

image

What should i do? thanks!

CodePudding user response:

Try this with more customization with button as per your requirement.

<androidx.appcompat.widget.AppCompatButton
    android:id="@ id/btn_scan_qr"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@drawable/rounded" //CREATE rounded.xml in res/drawable 
    android:text="7"
    android:textSize="15sp" />

rounded.xml in res/drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <!-- you can use any color you want I used here gray color-->
    <solid android:color="#ABABAB" />

    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />
    <size
        android:width="10dp"
        android:height="1dp" />
</shape>

CodePudding user response:

try this

  <com.google.android.material.button.MaterialButton
    android:id="@ id/button_7"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:text="7"
    android:textColor="#000000"
    app:cornerRadius="20dp"
 />

for using backgroud color just use app:backgroundTint="#334567". don't use background .. you are facing the problem because you have used both. just used one.

enter image description here

  • Related