Home > Net >  How to make a button with rounded edges?
How to make a button with rounded edges?

Time:01-06

what is the essence of the question:

  1. Why is the color that I write in solid in the shape not taken into account
  2. Why do I have a white background on the back of the button now (attached a photo)? I don't understand where I can fix itbackground button

I found a video on YouTube and there was the following solution: Create an xml file in drawable and there I specified the following:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="oval">
        <solid android:color="@color/teal_700"></solid>
    </shape>
</item>
</selector>

The problem is that when the videos came out, there were no themes and everything worked out perfectly right away, and I tried to figure out why I didn't apply color to the button if I set it in the shape, but I never figured it out and it doesn't take into account my color that I set in solid :) I decided to change the primaryColor in the theme to the color I needed and then it applied.

And can you also throw, please, useful modern resources to the latest versions of android studio? I'm just learning, so I haven't found much yet and it would be interesting to see some examples for new updates, because all the videos are from earlier versions and some of them don't converge, as, for example, now in the question

If there are not enough details to solve the problem, then write to me

CodePudding user response:

To make A Button Round Use MaterialButton

<com.google.android.material.button.MaterialButton
    android:layout_width="100dp"
    android:layout_height="50dp"
    android:text="1"
    app:cornerRadius="18dp" />
  • Related