MaterialButton with specific corners rounded
See original GitHub issueI am trying to make a button with only one side rounded (left or right).
Since the attribute app:cornerRadius
is applied to all four corners of the button, I’ve tried to set the background:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners
android:bottomLeftRadius="30dp"
android:topLeftRadius="30dp" />
</shape>
<android.support.design.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:background="@drawable/my_background"/>
But it didn’t work, because I suppose setting a custom background is not supported for it.
Any ideas how to reach only one rounded side for MaterialButton?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:5
Top Results From Across the Web
Rounded corners on material button - android - Stack Overflow
Use app:cornerRadius attribute to change the size of corner radius. This will round off the corners with specified dimensions. enter image description here....
Read more >Rounded Button in Android Studio - The Startup - Medium
Now , in the main xml file where you want the rounded corners for the button , add this line : android:background=”@drawable/rounded_corner ”...
Read more >rounded corner material button android Code Example
Answers related to “rounded corner material button android” ... Your Ruby version is 3.0.0, but your Gemfile specified 2.7.4 · Your Ruby version...
Read more >How to Android button rounded corners | Radius, ripple ...
To create an Android button rounded corners have to use a new XML file. This new XML file will be inside a drawable...
Read more >Shape theming - Material Design
Currently shape system for web only supports rounded corners. ... Styles for applying shapes for specific corners such as drawer looks like this:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tommybuonomo Pretty sure it’s supposed to be in pixels. Also, when I choose it this way, it becomes black and without any effect when clicking. How can I set it to just have this shape for the button, yet keep the color and the clicking effect ? I’ve also noticed that it’s deprecated and that we should use ShapeAppearanceModel instead: https://developer.android.com/reference/com/google/android/material/shape/ShapePathModel
So I think the correct way to do something like that could be like:
https://blog.octo.com/en/android-materialshapedrawable/
Example:
Hi @TanyaYu, You can achieve this working with MaterialShapeDrawable. You’ll be able to set custom corners treatments to the MaterialShapeDrawable, and apply it to your button.
For example: