I want to draw a perfect circular button. I tried using the following code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke
android:width="3dip"
android:color="#065a32" />
<corners android:radius="10dip"/>
<solid android:color="#eaebec" />
</shape>
But i was only able to draw an oval shape, even if i change the parameter:
<stroke
android:width="3dip"/>
<corners android:radius="10dip"/>
My Screenshot:
I already tried different links of this site but none of them fulfill my need.
Edit:
My code for getView() is:
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (convertView == null) {
LayoutInflater vi = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.calendar_item, null);
}
view.setBackgroundResource(R.drawable.calendar_cell_clicked);
}
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/actiivity_main. xml. In the above code, we have taken the button with a round_button background.
To create a rounded button you have to make use of the border-radius CSS property. The higher the value for that property the more rounder the corners will be. You can use any CSS unit for the boorder-radius property. It can be pixels, ems, rems, percentages etc.
Rounded corners HTML Buttons You can make rounded corners button by adding border-radius of 5px to 10px on HTML buttons.
Use the border-radius Property to Create a Circle Button in CSS. We can use the border-radius property to create a circle button in CSS. The property creates the rounded corners to the selected element by adding the radius to the element's corners.
use this xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid
android:color="#eaebec" />
</shape>
and in your layout where you are setting background use
android:layout_width="50dp"
android:layout_height="50dp"
or whatever size you need the circle to be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With